author | ysuenaga |
Wed, 30 Mar 2016 21:05:13 +0900 | |
changeset 37218 | c7241bc368bf |
parent 30846 | 2b3f379840f0 |
permissions | -rw-r--r-- |
21889
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
21889
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
21889
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
4 |
* |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
8 |
* |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
13 |
* accompanied this code). |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
14 |
* |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
18 |
* |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
21 |
* questions. |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
22 |
*/ |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
23 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
24 |
/* |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
25 |
* @test |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
26 |
* @bug 8028504 |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
27 |
* @summary javac generates LocalVariableTable even with -g:none |
30846 | 28 |
* @modules jdk.jdeps/com.sun.tools.classfile |
21889
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
29 |
* @compile -g:none DontGenerateLVTForGNoneOpTest.java |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
30 |
* @run main DontGenerateLVTForGNoneOpTest |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
31 |
*/ |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
32 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
33 |
import java.io.File; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
34 |
import java.lang.annotation.ElementType; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
35 |
import java.lang.annotation.Target; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
36 |
import java.nio.file.Paths; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
37 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
38 |
import com.sun.tools.classfile.Attribute; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
39 |
import com.sun.tools.classfile.ClassFile; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
40 |
import com.sun.tools.classfile.Code_attribute; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
41 |
import com.sun.tools.classfile.Method; |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
42 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
43 |
public class DontGenerateLVTForGNoneOpTest { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
44 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
46 |
new DontGenerateLVTForGNoneOpTest().run(); |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
47 |
} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
48 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
49 |
void run() throws Exception { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
50 |
checkClassFile(new File(Paths.get(System.getProperty("test.classes"), |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
51 |
this.getClass().getName() + ".class").toUri())); |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
52 |
} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
53 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
54 |
void checkClassFile(final File cfile) throws Exception { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
55 |
ClassFile classFile = ClassFile.read(cfile); |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
56 |
for (Method method : classFile.methods) { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
57 |
Code_attribute code = (Code_attribute)method.attributes.get(Attribute.Code); |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
58 |
if (code != null) { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
59 |
if (code.attributes.get(Attribute.LocalVariableTable) != null) { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
60 |
throw new AssertionError("LVT shouldn't be generated for g:none"); |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
61 |
} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
62 |
} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
63 |
} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
64 |
} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
65 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
66 |
public void bar() { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
67 |
try { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
68 |
System.out.println(); |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
69 |
} catch(@TA Exception e) { |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
70 |
} catch(Throwable t) {} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
71 |
} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
72 |
|
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
73 |
@Target(ElementType.TYPE_USE) |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
74 |
@interface TA {} |
7c3939a495ab
8028504: javac generates LocalVariableTable even with -g:none
vromero
parents:
diff
changeset
|
75 |
} |