You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by Anton Mironenko <am...@jnetx.ru> on 2005/08/23 17:06:28 UTC

Re[2]: java.lang.VerifyError: "method: signature: ()V) Call to wrong initialization method" after specifying superclass

Tuesday, August 23, 2005, 5:39:39 PM, dbrosius wrote:

dqn> Does SimpleClass have the appropriate super class
dqn> constructor call as it's first
dqn> instruction?

Even if SimpleClass has a constructor with no parameters in source
code,
I have the same exception.

May be compiler sees SimpleClass doesn't have superclass and ignores
this code?
So I need to add super(); into all constructors using BCEL?

How should I do this?

dqn> Quoting Anton Mironenko <am...@jnetx.ru>:

>> 
>> Hello,
>> 
>> I have two classes SimpleClass and SimpleSuperClass with no fields and
>> methods.
>> 
>> I need to specify superclass SimpleSuperClass for SimpleClass in BCEL.
>> 
>> When I'm trying to do this, I get the following exception when I
>> access the class with the code:
>> Class clazz = Class.forName( "com.jnetx.jdo.SimpleClass" );
>> 
>> java.lang.VerifyError: (class: com/jnetx/jdo/SimpleClass, method: <init>
>> signature: ()V) Call to wrong initialization method
>>         at java.lang.Class.forName0(Native Method)
>>         at java.lang.Class.forName(Class.java:141)
>>         at com.jnetx.jdo.TestBCEL.class$(TestBCEL.java:40)
>>         at
>> com.jnetx.jdo.TestBCEL.testCheckSimpleClass(TestBCEL.java:72)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>         at
>>
dqn> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>         at
>> com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
>> 
>> 
>> The code how I specify the superclass is the following:
>> 
>> 
>>         JavaClass jc = Repository.lookupClass( SimpleClass.class );
>>         ClassGen cg = new ClassGen( jc );
>> 
>>         cg.setSuperclassName( SimpleSuperClass.class.getName() );
>>         cg.update();
>> 
>>         String className = SimpleClass.class.getName();
>>         String path =
>> Repository.lookupClassFile(className).getPath();
>> 
>>         File f = new File(path);
>>         FileOutputStream fOut = null;
>>         try
>>         {
>>             fOut = new FileOutputStream(f);
>>             BufferedOutputStream bout = new BufferedOutputStream(fOut);
>> 
>>             cg.getJavaClass().dump(bout);
>>             bout.flush();
>> 
>>             bout.flush();
>>         }
>>         finally
>>         {
>>             try
>>             {
>>                 fOut.close();
>>                 fOut = null;
>>             }
>>             catch (Exception ignore)
>>             {
>>                 //ignore exception in closing the stream
>>             }
>>         }
>>         
>> 
>> What am I doing wrong?
>> 
>> Thanks.
>>         
>> ------------
>> Best regards,
>> Anton Mironenko
>> Software Engineer
>> jNETx LLC
>> tel. +7 095 780 790 0
>> mailto:amironenko@jnetx.ru
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>> 




------------
Best regards,
Anton Mironenko
Software Engineer
jNETx LLC
tel. +7 095 780 790 0
mailto:amironenko@jnetx.ru


---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org