Community
Participate
Working Groups
M9 + HEAD of 1_5 branch from CVS Executing the code shown below raises the following VM exception: java.lang.VerifyError: Expecting a stackmap frame at branch target 51 in method qwo.Qwo.load(Ljava/lang/String;)Ljava/lang/String; Exception in thread "main" public class Qwo { private static String load(String fileName) throws IOException { FileReader r = new FileReader(fileName); StringWriter w = new StringWriter(4096); char[] buf = new char[4096]; int count = r.read(buf); while (count > 0) { w.write(buf, 0, count); count = r.read(buf); } return w.toString(); } public static void main(String[] args) throws IOException { System.out.println(load("example.txt")); } }
Cannot reproduce. Given it has nothing specific to J2SE 1.5 support, can you reproduce it with plain M9 build ? Also, can you describe the compiler settings you are using ? This could only occur in some given configuration.
Please reopen once requested information is available.
I can easily reproduce the problem. I'm using M9. I downloaded the lastest 1_5 branch of jdt.core from CVS (just a few minutes ago). I launched that as a runtime workbench using JRE 1.4.2_03. In that workbench, I changed the default JRE to 1.5.0 beta1 and the compiler compliance level to 1.5. I didn't change anything else. I created a test project with a test class (without package) and entered the code posted earlier. If I try to run it, I get the exception. If I switch the compiler compliance level back to 1.4, it works. Therefore, I assume that it has to do with cheetah. The code also works without problem in a naked M9. I checked for a .log file but there's none.
Created attachment 11018 [details] Class file that causes the VerifyError
Disassembled classfile is: D:\>javap -c -private Test Compiled from "Test.java" public class Test extends java.lang.Object{ public Test(); Code: 0: aload_0 1: invokespecial #9; //Method java/lang/Object."<init>":()V 4: return private static java.lang.String load(java.lang.String) throws java.io.IOException; Code: 0: new #20; //class java/io/FileReader 3: dup 4: aload_0 5: invokespecial #23; //Method java/io/FileReader."<init>": (Ljava/lang/String;)V 8: astore_1 9: new #25; //class java/io/StringWriter 12: dup 13: sipush 4096 16: invokespecial #28; //Method java/io/StringWriter."<init>":(I)V 19: astore_2 20: sipush 4096 23: newarray char 25: astore_3 26: aload_1 27: aload_3 28: invokevirtual #32; //Method java/io/FileReader.read:([C)I 31: istore 4 33: goto 51 36: aload_2 37: aload_3 38: iconst_0 39: iload 4 41: invokevirtual #36; //Method java/io/StringWriter.write:([CII)V 44: aload_1 45: aload_3 46: invokevirtual #32; //Method java/io/FileReader.read:([C)I 49: istore 4 51: iload 4 53: ifgt 36 56: aload_2 57: invokevirtual #40; //Method java/io/StringWriter.toString:() Ljava/lang/String; 60: areturn public static void main(java.lang.String[]) throws java.io.IOException; Code: 0: getstatic #58; //Field java/lang/System.out:Ljava/io/PrintStream; 3: ldc #60; //String 5: invokestatic #62; //Method load:(Ljava/lang/String;) Ljava/lang/String; 8: invokevirtual #67; //Method java/io/PrintStream.println: (Ljava/lang/String;)V 11: return }
Still cannot reproduce. My generated file is strictly the same as yours, and mine is executed without any problem by 1.5 VM.
I think, I found the problem. It's a bug related to 1.5.0-beta1-b31 (javalobby alpha version). I tried another computer where I've 1.5.0-beta1-b32c (official beta1 I think) installed. Now it works. Time to upgrade my version... You can close the bug. Thanks for your patience :)
Ok, thanks for letting us know. I was indeed trying to reproduce on b32c or better.
*** Bug 63988 has been marked as a duplicate of this bug. ***