![]() |
.. (לתיקייה המכילה) | |
Where can I find a computer where Java is installed? | |
There is a full installation of Java on the T2. javac = The Java compiler, java = the JVM |
Can I use java.util.HashSet collection in order to add() strings such that each string will be contained only once? | |
Yes |
How flexible/generic/etc do you expect our design to be? Are we expected to design and implement some abstraction over metrics and write generic code that computes them? | |
You are not required to develop a generic framework for metrics. |
It turns out that the JarScanner class (from the demo program) crashes for some jar files, and therefore, our program as well. Is it ok for our program not to handle jar files that JarScanner cannot handle? | |
Yes it is ok. (Although most .class files are platform independent, some classes are, in fact, platform specific. For example: There are several classes that provide basic user-interface services, one for each operating system. Trying to load the Windows class on a Unix machine may crash the program) |
OVRR(X) is defined as the number of methods in the input that override methods of X. Do I need to calculate it for every method and sum it up? | |
OVRR is defined over classes. As you suggest, the general algorithm is to find all the methods which overridde methods of X and count them. |
Can you explain the commands for compiling running a java program from a unix shell? | |
(This answer applies to both Unix and Windows systems) Compilation: javac -d bin -sourcepath src src/oop/asgn4/Main.java This compiles the file src/oop/asgn4/Main.java. the "-d bin" option tells the compiler that the output files (*.class files) should be placed under the bin/ directory. The "-sourcepath src" options tells the compiler that all source files (*.java) are located under the src/ directory Running a program: java -cp bin oop.asgn4.Main input.jar This command runs the java program whose main class is oop.asgn4.Main. The "-cp bin" option specifies that all *.class files are located under the bin/ directory. "input.jar" is the parameter which will be passed to main() method |
When you say that the program should find all cases where an interface method is overridden, what definition of overridding are you using? | |
Here is the criteria: A method m in a class C overriddes a method m in an interface A if a Java code that calls A.m() may result in C.m() being invoked. For instance:
(Arguments passed to the constructor of C and to m() are omitted from this snip) The the full formal definition can be found at The Java language specification, article 8.4 |
I noticed that there are some differences between Java 1.4 and Java 1.5 regarding the definition of overridding. Which definition should my program use? | |
You should stick to the defintion of 1.4 which is a little bit simpler to implement. Note that you can still write your code in Java 1.5 (The difference between the two definitions is due to the support - in Java 1.5 - for covariant return type) |
When I compile my program using Java 1.5, I get the following message | |
Basically, it means that your code downcasts from Object to something else instead of using genericity. You can either ignore it (if you are sure all your downcasts are correct) or start using generic collections: For instance, you can use Hashtable<String,Class> instead of Hashtable. |
When you say "class name" do you mean | |
I mean the fully-qualified-name, i.e: java.util.Vector |
I see that the PDF document which describes the assignment is now called "oop-asgn4.2.pdf". Is it different from the previous document? | |
The new document fixes typos which were found in the previous one. It also clarifies the expected output. |
When I run the program on 1200.jar I get all sort of weird messages printed on the screen. There is also one message box which pops up. Is this normal? | |
several classes in this file print messages while being loaded (and one of them even displays a message box on your screen). Since these messages are written to the stderr stream (System.err) they do not affect the output of your program which is written to the stdout stream (System.out) |
We noticed that our program failed to load some of the classes in the 1200.jar file. What should we do with these classes? | |
The main point is that your program should handle all the classes which the demo program handles. If the demo program can processe a class which your program fails to handle, then there is some sort of a problem in your code which you should solve. |