Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
5.2
-
None
-
None
Description
I used the BCEL v5.2 to do experiments on my test cases, and met the following problem:
D:\java test._Test10 Exception in thread "main" java.lang.ClassFormatError: LVTT entry for 'ht' in class file test/_Test10 does not match any LVT entry at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: test._Test10. Program will exit.
My test case is as follows:
public class _Test10 { public static void main (String [] args) { HashMap <Double,Integer> ht = new HashMap<Double,Integer>(); } }
Using BCEL, I didn't make any change of the original Method. Using it, I generated a new Method and replaced it with the new one.
ClassGen _cg = new ClassGen(_claz); for (Method oldMethod : _inMethods) { MethodGen mg = new MethodGen(oldMethod, _inClass.getClassName(), _cpg); Method newMethod = mg.getMethod(); _cg.replaceMethod(oldMethod, newMethod); }