Re[2]: java.lang.VerifyError: "method: <init> signature: ()V) Call to wrong initialization method" after specifying superclass
Anton Mironenko <[email protected]> Tue, 23 Aug 2005 19:06:28 +0400
| Newsgroups | gmane.comp.jakarta.bcel.user |
|---|---|
| Organization | jnetx |
| Message-ID | <[email protected]> |
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 <[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 >> 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:[email protected] >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> ------------ Best regards, Anton Mironenko Software Engineer jNETx LLC tel. +7 095 780 790 0 mailto:[email protected]