From: <cr...@us...> - 2009-09-12 03:49:26
|
Revision: 5679 http://jnode.svn.sourceforge.net/jnode/?rev=5679&view=rev Author: crawley Date: 2009-09-12 03:49:18 +0000 (Sat, 12 Sep 2009) Log Message: ----------- Added diagnostics for problems using a classes constant pool. Modified Paths: -------------- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-09-10 14:36:30 UTC (rev 5678) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-09-12 03:49:18 UTC (rev 5679) @@ -456,7 +456,7 @@ createFields(cls, fieldData, sharedStatics, isolatedStatics, slotSize, cls.getPragmaFlags()); } - + cp.setParentType(cls); return cls; } Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java 2009-09-10 14:36:30 UTC (rev 5678) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java 2009-09-12 03:49:18 UTC (rev 5679) @@ -255,8 +255,10 @@ itable[0] = new VmImplementedInterface(annType); implType.setInterfaceTable(itable); - return (VmNormalClass<? extends ImplBase>) loader - .defineClass(implType); + VmNormalClass<? extends ImplBase> res = (VmNormalClass<? extends ImplBase>) + loader.defineClass(implType); + cp.setParentType(res); + return res; } /** Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-09-10 14:36:30 UTC (rev 5678) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-09-12 03:49:18 UTC (rev 5679) @@ -55,6 +55,8 @@ private Object[] cp; private int used; + + private VmType parentType; /** * Construct a new VmCP with a given number of entries @@ -84,8 +86,15 @@ public int getInt(int index) { if (index == 0) return 0; - else - return ((VmConstInt) get(index)).intValue(); + else { + try { + return ((VmConstInt) get(index)).intValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstInt"); + } + } } /** @@ -105,7 +114,13 @@ * @return long */ public long getLong(int index) { - return ((VmConstLong) get(index)).longValue(); + try { + return ((VmConstLong) get(index)).longValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstLong"); + } } /** @@ -125,7 +140,13 @@ * @return float */ public float getFloat(int index) { - return ((VmConstFloat) get(index)).floatValue(); + try { + return ((VmConstFloat) get(index)).floatValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstFloat"); + } } /** @@ -145,7 +166,13 @@ * @return double */ public double getDouble(int index) { - return ((VmConstDouble) get(index)).doubleValue(); + try { + return ((VmConstDouble) get(index)).doubleValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstDouble"); + } } /** @@ -159,23 +186,41 @@ } protected String getUTF8(int index) { - return (String) get(index); + try { + return (String) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a String"); + } } protected void setUTF8(int index, String value) { - set(index, InternString.internString(value)); + set(index, InternString.internString(value)); } public VmConstString getString(int index) { - return (VmConstString) get(index); + try { + return (VmConstString) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstString"); + } } protected void setString(int index, VmConstString value) { - set(index, value); + set(index, value); } public VmConstClass getConstClass(int index) { - return (VmConstClass) get(index); + try { + return (VmConstClass) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstClass"); + } } protected void setConstClass(int index, VmConstClass value) { @@ -183,7 +228,13 @@ } public VmConstFieldRef getConstFieldRef(int index) { - return (VmConstFieldRef) get(index); + try { + return (VmConstFieldRef) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstFieldRef"); + } } protected void setConstFieldRef(int index, VmConstFieldRef value) { @@ -191,7 +242,13 @@ } public VmConstMethodRef getConstMethodRef(int index) { - return (VmConstMethodRef) get(index); + try { + return (VmConstMethodRef) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstMethodRef"); + } } protected void setConstMethodRef(int index, VmConstMethodRef value) { @@ -199,7 +256,13 @@ } public VmConstIMethodRef getConstIMethodRef(int index) { - return (VmConstIMethodRef) get(index); + try { + return (VmConstIMethodRef) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstIMethodRef"); + } } protected void setConstIMethodRef(int index, VmConstIMethodRef value) { @@ -253,4 +316,12 @@ final void reset(int index) { cp[index] = null; } + + public VmType getParentType() { + return parentType; + } + + public void setParentType(VmType parentType) { + this.parentType = parentType; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |