Re: java.lang.VerifyError: "method: <init> signature: ()V) Call to wrong initialization method" after specifying superclass

[email protected] Tue, 23 Aug 2005 09:39:39 -0400
Newsgroups gmane.comp.jakarta.bcel.user
Message-ID <[email protected]>
Does SimpleClass have the appropriate super class constructor call as it's first
instruction?


Quoting Anton Mironenko <[email protected]>:

> 
> 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
>
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:[email protected]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>