1 /* 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 8049632 27 * @summary Test ClassFileParser::copy_localvariable_table cases 28 * @library /test/lib 29 * @modules java.base/jdk.internal.misc 30 * java.management 31 * @compile -g -XDignore.symbol.file TestLVT.java 32 * @run main TestLVT 33 */ 34 35 import jdk.test.lib.process.ProcessTools; 36 import jdk.test.lib.process.OutputAnalyzer; 37 import java.util.*; 38 39 public class TestLVT { 40 public static void main(String[] args) throws Exception { 41 test(); // Test good LVT in this test 42 43 String jarFile = System.getProperty("test.src") + "/testcase.jar"; 44 45 // java -cp $testSrc/testcase.jar DuplicateLVT 46 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "DuplicateLVT"); 47 new OutputAnalyzer(pb.start()) 48 .shouldContain("Duplicated LocalVariableTable attribute entry for 'by' in class file DuplicateLVT") 49 .shouldHaveExitValue(1); 50 51 // java -cp $testclasses/testcase.jar DuplicateLVTT 52 pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "DuplicateLVTT"); 53 new OutputAnalyzer(pb.start()) 54 .shouldContain("Duplicated LocalVariableTypeTable attribute entry for 'list' in class file DuplicateLVTT") 55 .shouldHaveExitValue(1); 56 57 // java -cp $testclasses/testcase.jar NotFoundLVTT 58 pb = ProcessTools.createJavaProcessBuilder("-cp", jarFile, "NotFoundLVTT"); 59 new OutputAnalyzer(pb.start()) 60 .shouldContain("LVTT entry for 'list' in class file NotFoundLVTT does not match any LVT entry") 61 .shouldHaveExitValue(1); 62 } 63 64 public static void test() { 65 boolean b = true; 66 byte by = 0x42; 67 char c = 'X'; 68 double d = 1.1; 69 float f = (float) 1.2; 70 int i = 42; 71 long l = 0xCAFEBABE; 72 short s = 88; 73 ArrayList<String> list = new ArrayList<String>(); 74 list.add("me"); 75 76 System.out.println("b=" + b); 77 System.out.println("by=" + by); 78 System.out.println("c=" + c); 79 System.out.println("d=" + d); 80 System.out.println("f=" + f); 81 System.out.println("i=" + i); 82 System.out.println("l=" + l); 83 System.out.println("s=" + s); 84 System.out.println("ArrayList<String>=" + list); 85 } 86 }