Path: blob/master/test/hotspot/jtreg/runtime/LocalVariableTable/TestLVT.java
40942 views
/*1* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 804963226* @summary Test ClassFileParser::copy_localvariable_table cases27* @library /test/lib28* @modules java.base/jdk.internal.misc29* java.management30* @compile DuplicateLVT.jcod DuplicateLVTT.jcod NotFoundLVTT.jcod31* @compile -g -XDignore.symbol.file TestLVT.java32* @run main TestLVT33*/3435import jdk.test.lib.process.ProcessTools;36import jdk.test.lib.process.OutputAnalyzer;37import java.util.*;3839public class TestLVT {40public static void main(String[] args) throws Exception {41test(); // Test good LVT in this test4243String jarFile = System.getProperty("test.src") + "/testcase.jar";4445// java -cp $testSrc/testcase.jar DuplicateLVT46ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("DuplicateLVT");47new OutputAnalyzer(pb.start())48.shouldContain("Duplicated LocalVariableTable attribute entry for 'by' in class file DuplicateLVT")49.shouldHaveExitValue(1);5051// java -cp $testclasses/testcase.jar DuplicateLVTT52pb = ProcessTools.createJavaProcessBuilder("DuplicateLVTT");53new OutputAnalyzer(pb.start())54.shouldContain("Duplicated LocalVariableTypeTable attribute entry for 'list' in class file DuplicateLVTT")55.shouldHaveExitValue(1);5657// java -cp $testclasses/testcase.jar NotFoundLVTT58pb = ProcessTools.createJavaProcessBuilder("NotFoundLVTT");59new OutputAnalyzer(pb.start())60.shouldContain("LVTT entry for 'list' in class file NotFoundLVTT does not match any LVT entry")61.shouldHaveExitValue(1);62}6364public static void test() {65boolean b = true;66byte by = 0x42;67char c = 'X';68double d = 1.1;69float f = (float) 1.2;70int i = 42;71long l = 0xCAFEBABE;72short s = 88;73ArrayList<String> list = new ArrayList<String>();74list.add("me");7576System.out.println("b=" + b);77System.out.println("by=" + by);78System.out.println("c=" + c);79System.out.println("d=" + d);80System.out.println("f=" + f);81System.out.println("i=" + i);82System.out.println("l=" + l);83System.out.println("s=" + s);84System.out.println("ArrayList<String>=" + list);85}86}878889