We use this in cglib without problems on sun jdk implementations, reflection is used to invoke protected method, but it is possible to extend ClassLoader and call this method "normal" way if you do not need to cast generated classes or accsess superclass loaded by different classloaders.
I am extending a classloader to add in the new classes. It seems to work OK, but I need to solve another problem.
The problem according to JustIce is this:
Instruction getfield[180](3) 18 constraint violated: Referenced field 'm_contentHandler' does not exist in class 'test_xml'.
The class that "test_xml" is a generated as a subclass of AbstractXMLSource--which has m_contentHandler as a protected member.
The generated class provides me the following error from the classloader:
-----------------------------------------------------
Compiling an XMLSource from an XML file
Printing the XMLSource out
Exception in thread "main" java.lang.VerifyError: (class: test_xml, method: parse signature: ()V) Incompatible type for getting or setting field
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
at java.lang.Class.getConstructor0(Class.java:1762)
at java.lang.Class.newInstance0(Class.java:276)
at java.lang.Class.newInstance(Class.java:259)
at org.d_haven.bxml.compiler.Main.main(Main.java:70)
-----------------------------------------------------
Using JustIce, I get this:
JustIce by Enver Haase, (C) 2001-2002. <http://bcel.sourceforge.net> <http://jakarta.apache.org/bcel>
Now verifying: test_xml
Pass 1: VERIFIED_OK Passed verification.
Pass 2: VERIFIED_OK Passed verification.
Pass 3a, method number 0 ['public void <init>()']: VERIFIED_OK Passed verification.
Pass 3b, method number 0 ['public void <init>()']: VERIFIED_OK Passed verification.
Pass 3a, method number 1 ['public void parse()
throws org.xml.sax.SAXException']:
VERIFIED_REJECTED
Instruction getfield[180](3) 18 constraint violated: Referenced field 'm_contentHandler' does not exist in class 'test_xml'.
Pass 3b, method number 1 ['public void parse()
throws org.xml.sax.SAXException']:
VERIFIED_NOTYET
Not yet verified.Pass 3a, method number 2 ['static void <clinit>()']: VERIFIED_OK Passed verification.
Pass 3b, method number 2 ['static void <clinit>()']: VERIFIED_OK Passed verification.
Warnings:
Pass 2: Attribute '<LocalVariableTable: LocalVariable(start_pc = 0, length = 5,
index = 0:test_xml this)>' as an attribute of Code attribute '<CODE>' (method 'public void <init>()') will effectively be ignored and is only useful for debuggers and such.
Pass 2: Attribute '<LocalVariableTable: LocalVariable(start_pc = 0, length = 101
, index = 0:test_xml this)>' as an attribute of Code attribute '<CODE>' (method
'public void parse()
throws org.xml.sax.SAXException') will effectively be ignored and is only useful for debuggers and such.
Pass 2: Class or interface initialization method 'static void <clinit>()' has superfluous access modifier(s) set: everything but ACC_STRICT is ignored.
Pass 2: SourceFile attribute 'SourceFile(test.xml)' has a funny name: remember not to confuse certain parsers working on javap's output. Also, this name ('test.xml') is considered an unqualified (simple) file name only.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
