To execute various queries, Derby generates Java classes on the fly, then executes that generated code.
To study a particular Derby issue, you may find yourself wanting to view that generated code. For example, DERBY-2352 involves understanding what code is generated for various expressions. DERBY-739 is another example.
Here's a simple technique that will allow you to view the generated code:
Run Derby with the argument -Dderby.debug.true=DumpClassFile:
java -Dderby.debug.true=DumpClassFile org.apache.derby.tools.ij
- Reproduce the problem that you're interested in. It's best if you can narrow the problem down to a single statement that you can execute in your IJ session.
- Exit IJ and look in your current directory. You'll see a file like:
ac601a400fx0116x4ec6xd381x00000010e1180.class This is the generated class file for the statement you just ran.
Use a decompiler to transform the generated Java class into source code. I've been successful using "jad". Others have used javap -c. Still others have used 'jode' (see below).
- Now you can read the code!
Some other information about generated class files is documented here: https://builds.apache.org/job/Derby-trunk/lastSuccessfulBuild/artifact/trunk/javadoc/engine/index.html
A shell script for using the 'jode' decompiler
This shell script may prove useful if you are using the 'jode' decompiler to view the generated class file's code:
# # Run the jode decompiler on a class. E.g.: # # runjode acf81e0010x011cxddd8xfcabx0000000feab00 classStub=$1 . setupClasspath export CLASSPATH=$CLASSPATH:$SW/javaDecompilers/jode/jode-1.1.2-pre1.jar:. echo $CLASSPATH mkdir org mkdir org/apache mkdir org/apache/derby mkdir org/apache/derby/exe cp $classStub.class org/apache/derby/exe/ #java -cp $CLASSPATH jode.decompiler.Main --help $* java -cp $CLASSPATH jode.decompiler.Main org.apache.derby.exe.$classStub