Java Reference
In-Depth Information
Exercise 1.14. Write a j-- program Palindrome.java that accepts a string as input, and
outputs the string if it is a palindrome (a string that reads the same in either direction),
and outputs nothing if it is not. The program should be case-insensitive to the input. For
example 17 :
>javaPalindromeMalayalam
should output:
>Malayalam
Exercise 1.15. Suggest enhancements to the j-- language that would simplify the imple-
mentation of the programs described in the previous exercises (1.10 through 1.14).
Exercise 1.16. For each of the j-- programs described in Exercises 1.10 through 1.14, write
a JUnit test case and integrate it with the j-- test framework (Appendix A describes how
this can be done).
Exercises 1.17 through 1.25 give the reader practice in reading JVM code and using
CLEmitter for producing JVM code (in the form of .class files). The JVM and the CLEmitter
are described in Appendix D.
Exercise 1.17. Disassemble (Appendix A describes how this can be done) a Java class
(say java.util.ArrayList ), study the output, and list the following:
Major and minor version
Size of the constant pool table
Super class
Interfaces
Field names, their access modifiers, type descriptors, and their attributes (just names)
Method names, their access modifiers, descriptors, exceptions thrown, and their
method and code attributes (just names)
Class attributes (just names)
Exercise 1.18. Compile $j/j--/tests/pass/HelloWorld.java using the j-- compiler and
Oracle's javac compiler. Disassemble the class le produced by each and compare the output.
What differences do you see?
Exercise 1.19. Disassemble the class file produced by the j-- compiler for $j/j--/tests/
pass/Series.java , save the output in Series.bytecode . Add a single-line ( //... ) com-
ment for each JVM instruction in Series.bytecode explaining what the instruction does.
Exercise 1.20. Write the following class names in internal form:
java.lang.Thread
java.util.ArrayList
java.io.FileNotFoundException
17 Malayalam is the language spoken in Kerala, a southern Indian state.
 
Search WWH ::




Custom Search