|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ bytecode overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.services.bytecode
Class BCJava

java.lang.Objectorg.apache.derby.impl.services.bytecode.BCJava
- All Implemented Interfaces:
- org.apache.derby.iapi.services.cache.CacheableFactory, org.apache.derby.iapi.services.compiler.JavaFactory, org.apache.derby.iapi.services.monitor.ModuleControl
- public class BCJava
- extends java.lang.Object
- implements org.apache.derby.iapi.services.compiler.JavaFactory, org.apache.derby.iapi.services.cache.CacheableFactory, org.apache.derby.iapi.services.monitor.ModuleControl
- extends java.lang.Object
Debugging problems with generated classes
When the code has been generated incorrectly, all sorts of odd things can go wrong. This is one recommended approach to finding the problem.
First, turn on ByteCodeGenInstr and DumpClassFile. Look for missing files (right now they are consecutively numbered by the activation class builder; later on they won't be, but BytCodeGenInstr dumps messages about the classes it has). Look at the log to make sure that all "GEN starting class/method" messages are paired with a "GEN ending class/method" message. If a file is missing or the pairing is missing, then something went wrong when the system tried to generate the bytecodes. Resort to your favorite debugging tool to step through the faulty statement.
If you get class files but the system crashes on you (I had an OS segmentation fault once) or you get funny messages like JDBC Excpetion: ac5 where ac5 is just the name of a generated class, then one of the following is likely:
- you are calling INVOKEVIRTUAL when you are supposed to call INVOKEINTERFACE
- you have an inexact match on a method argument or return type.
- you are trying to get to a superclass's field using a subclass.
- javap -c -v ac5 >ac5.gp
if javap reports "Class not found", and the file ac5.class does exist in the current directory, then the .class file is probably corrupt. Try running mocha on it to see if that works. The problem will be in the code that generates the entries for the class file -- most likely the ConstantPool is bad, an attribute got created incorrectly, or perhaps the instruction streams are goofed up. - java mocha.Decompiler ac5.class
if mocha cannot create good java source, then you really need to go back and examine the calls creating the java constructs; a parameter might have been null when it should have, a call to turn an expression into a statement may be missing, or something else may be wrong. - mv ac5.mocha ac5.java
- vi ac5.java ; you will have to fix any new SQLBoolean(1, ...) calls to be new SQLBoolean(true, ...). Also mocha occasionally messes up other stuff too. Just iterate on it until it builds or you figure out what is wrong with the generated code.
- javac ac5.java
- javap -v -c ac5 >ac5.jp
- sed '1,$s/#[0-9]* # ' ac5.gp > ac5.gn
- sed '1,$s/#[0-9]* # ' ac5.jp > ac5.jn
These seds are to get rid of constant pool entry numbers, which will be wildly different on the two files. - vdiff32 ac5.gn ac5.jn
this tool shows you side-by-side diffs. If you change to the window that interleaves the diffs, you can see the length of the line. Look for places where there are invokevirtual vs. invokeinterface differences, differences in the class name of a field, differences in the class name of a method parameter or return type. The generated code will* have some unavoidable differences from the compiled code, such as:- it will have goto's at the end of try blocks rather than return's.
- it will do a getstatic on a static final field rather than inlining the static final field's value
- it will have more checkcast's in it, since it doesn't see if the checkcast will always succeed and thus remove it.
| Field Summary | |
private org.apache.derby.iapi.services.cache.CacheManager |
vmTypeIdCache
|
| Fields inherited from interface org.apache.derby.iapi.services.compiler.JavaFactory |
JAVA_FACTORY_PROPERTY |
| Constructor Summary | |
BCJava()
|
|
| Method Summary | |
void |
boot(boolean create,
java.util.Properties properties)
Start this module. |
org.apache.derby.iapi.services.cache.Cacheable |
newCacheable(org.apache.derby.iapi.services.cache.CacheManager cm)
|
org.apache.derby.iapi.services.compiler.ClassBuilder |
newClassBuilder(org.apache.derby.iapi.services.loader.ClassFactory cf,
java.lang.String packageName,
int modifiers,
java.lang.String className,
java.lang.String superClass)
a class. |
void |
stop()
Stop this module. |
(package private) Type |
type(java.lang.String javaType)
Get the VM Type ID that corresponds with the given java type name. |
(package private) java.lang.String |
vmType(BCMethodDescriptor md)
|
(package private) static short |
vmTypeId(java.lang.String vmTypeS)
Map vm types as strings to vm types as the VM handles, with int ids. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
vmTypeIdCache
private org.apache.derby.iapi.services.cache.CacheManager vmTypeIdCache
| Constructor Detail |
BCJava
public BCJava()
| Method Detail |
boot
public void boot(boolean create,
java.util.Properties properties)
throws org.apache.derby.iapi.error.StandardException
- Start this module. We need a read/write version of the class utilities
- Specified by:
bootin interfaceorg.apache.derby.iapi.services.monitor.ModuleControl
stop
public void stop()
- Stop this module. In this case, nothing needs to be done.
- Specified by:
stopin interfaceorg.apache.derby.iapi.services.monitor.ModuleControl
newClassBuilder
public org.apache.derby.iapi.services.compiler.ClassBuilder newClassBuilder(org.apache.derby.iapi.services.loader.ClassFactory cf, java.lang.String packageName, int modifiers, java.lang.String className, java.lang.String superClass)
- a class. Once it is created, fields, methods,
interfaces, static initialization code,
and constructors can be added to it.
Java: package #packageName; #modifiers #className extends #superClass { } // modifiers is the | of the JVM constants for // the modifiers such as static, public, etc. - Specified by:
newClassBuilderin interfaceorg.apache.derby.iapi.services.compiler.JavaFactory
newCacheable
public org.apache.derby.iapi.services.cache.Cacheable newCacheable(org.apache.derby.iapi.services.cache.CacheManager cm)
- Specified by:
newCacheablein interfaceorg.apache.derby.iapi.services.cache.CacheableFactory
type
Type type(java.lang.String javaType)
- Get the VM Type ID that corresponds with the given java type name.
This uses the cache of VM type ids.
vmType
java.lang.String vmType(BCMethodDescriptor md)
vmTypeId
static short vmTypeId(java.lang.String vmTypeS)
- Map vm types as strings to vm types as the VM
handles, with int ids. Used in mapping opcodes
based on type of operand/stack entry available.
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ bytecode overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derby.impl.services.bytecode.BCJava