View | Details | Raw Unified | Return to bug 143718 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java (-1 / +90 lines)
Lines 33-39 Link Here
33
	static {
33
	static {
34
//		TESTS_PREFIX = "testBug95521";
34
//		TESTS_PREFIX = "testBug95521";
35
//		TESTS_NAMES = new String[] { "testBug83127a" };
35
//		TESTS_NAMES = new String[] { "testBug83127a" };
36
//		TESTS_NUMBERS = new int[] { 7 };
36
//		TESTS_NUMBERS = new int[] { 8 };
37
//		TESTS_RANGE = new int[] { 23, -1 };
37
//		TESTS_RANGE = new int[] { 23, -1 };
38
	}
38
	}
39
	public static Test suite() {
39
	public static Test suite() {
Lines 825-828 Link Here
825
				assertEquals("Wrong contents", expectedOutput, actualOutput);
825
				assertEquals("Wrong contents", expectedOutput, actualOutput);
826
			}
826
			}
827
	}
827
	}
828
	
829
	public void test008() {
830
		this.runConformTest(
831
				new String[] {
832
					"X.java",
833
					"public class X {\n" + 
834
					"	String s;\n" + 
835
					"	X() {\n" + 
836
					"        int i = 0;\n" + 
837
					"        if (s == null) {\n" + 
838
					"        	System.out.print(\"PASSED\");\n" + 
839
					"        } else {\n" + 
840
					"        	System.out.print(\"FAILED\");\n" + 
841
					"        }\n" + 
842
					"        System.out.print(\"DONE\" + i);\n" + 
843
					"	}\n" + 
844
					"    public static void main(String argv[]) {\n" + 
845
					"    	new X();\n" + 
846
					"    }\n" + 
847
					"}",
848
				},
849
				"PASSEDDONE0");
850
				
851
			ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
852
			String actualOutput = null;
853
			try {
854
				byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
855
				actualOutput =
856
					disassembler.disassemble(
857
						classFileBytes,
858
						"\n",
859
						ClassFileBytesDisassembler.DETAILED); 
860
			} catch (org.eclipse.jdt.core.util.ClassFormatException e) {
861
				assertTrue("ClassFormatException", false);
862
			} catch (IOException e) {
863
				assertTrue("IOException", false);
864
			}
865
			
866
			String expectedOutput = 
867
				"  // Method descriptor #8 ()V\n" + 
868
				"  // Stack: 4, Locals: 2\n" + 
869
				"  X();\n" + 
870
				"     0  aload_0 [this]\n" + 
871
				"     1  invokespecial java.lang.Object() [10]\n" + 
872
				"     4  iconst_0\n" + 
873
				"     5  istore_1 [i]\n" + 
874
				"     6  aload_0 [this]\n" + 
875
				"     7  getfield X.s : java.lang.String [12]\n" + 
876
				"    10  ifnonnull 24\n" + 
877
				"    13  getstatic java.lang.System.out : java.io.PrintStream [14]\n" + 
878
				"    16  ldc <String \"PASSED\"> [20]\n" + 
879
				"    18  invokevirtual java.io.PrintStream.print(java.lang.String) : void [22]\n" + 
880
				"    21  goto 32\n" + 
881
				"    24  getstatic java.lang.System.out : java.io.PrintStream [14]\n" + 
882
				"    27  ldc <String \"FAILED\"> [28]\n" + 
883
				"    29  invokevirtual java.io.PrintStream.print(java.lang.String) : void [22]\n" + 
884
				"    32  getstatic java.lang.System.out : java.io.PrintStream [14]\n" + 
885
				"    35  new java.lang.StringBuilder [30]\n" + 
886
				"    38  dup\n" + 
887
				"    39  ldc <String \"DONE\"> [32]\n" + 
888
				"    41  invokespecial java.lang.StringBuilder(java.lang.String) [34]\n" + 
889
				"    44  iload_1 [i]\n" + 
890
				"    45  invokevirtual java.lang.StringBuilder.append(int) : java.lang.StringBuilder [36]\n" + 
891
				"    48  invokevirtual java.lang.StringBuilder.toString() : java.lang.String [40]\n" + 
892
				"    51  invokevirtual java.io.PrintStream.print(java.lang.String) : void [22]\n" + 
893
				"    54  return\n" + 
894
				"      Line numbers:\n" + 
895
				"        [pc: 0, line: 3]\n" + 
896
				"        [pc: 4, line: 4]\n" + 
897
				"        [pc: 6, line: 5]\n" + 
898
				"        [pc: 13, line: 6]\n" + 
899
				"        [pc: 24, line: 8]\n" + 
900
				"        [pc: 32, line: 10]\n" + 
901
				"        [pc: 54, line: 11]\n" + 
902
				"      Local variable table:\n" + 
903
				"        [pc: 0, pc: 55] local: this index: 0 type: X\n" + 
904
				"        [pc: 6, pc: 55] local: i index: 1 type: int\n" + 
905
				"      Stack map table: number of frames 2\n" + 
906
				"        [pc: 24, full, stack: {}, locals: {X, int}]\n" + 
907
				"        [pc: 32, same]\n";
908
			
909
			int index = actualOutput.indexOf(expectedOutput);
910
			if (index == -1 || expectedOutput.length() == 0) {
911
				System.out.println(Util.displayString(actualOutput, 2));
912
			}
913
			if (index == -1) {
914
				assertEquals("Wrong contents", expectedOutput, actualOutput);
915
			}
916
	}
828
}
917
}

Return to bug 143718