author | mchung |
Wed, 27 May 2015 13:25:18 -0700 | |
changeset 30846 | 2b3f379840f0 |
parent 30730 | d3ce7619db2c |
child 37638 | aac00923d48e |
permissions | -rw-r--r-- |
24896
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
24896
diff
changeset
|
2 |
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
24896
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
4 |
* |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
8 |
* |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
13 |
* accompanied this code). |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
14 |
* |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
18 |
* |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
21 |
* questions. |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
22 |
*/ |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
23 |
|
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
24 |
/* |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
25 |
* @test |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
26 |
* @bug 8042451 |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
27 |
* @summary Test population of reference info for resource variable |
30846 | 28 |
* @modules jdk.jdeps/com.sun.tools.classfile |
24896
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
29 |
* @compile -g Driver.java ReferenceInfoUtil.java ResourceVariable.java |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
30 |
* @run main Driver ResourceVariable |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
31 |
*/ |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
32 |
|
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
33 |
import static com.sun.tools.classfile.TypeAnnotation.TargetType.RESOURCE_VARIABLE; |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
34 |
import static java.lang.System.lineSeparator; |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
35 |
|
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
36 |
public class ResourceVariable { |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
37 |
|
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
38 |
@TADescription(annotation = "TA", type = RESOURCE_VARIABLE, |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
39 |
lvarOffset = {10}, lvarLength = {118}, lvarIndex = {1}) |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
40 |
@TADescription(annotation = "TB", type = RESOURCE_VARIABLE, |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
41 |
lvarOffset = {22}, lvarLength = {35}, lvarIndex = {3}) |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
42 |
public String testResourceVariable() { |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
43 |
return |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
44 |
"public void f() throws IOException {" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
45 |
" try (@TA InputStream is1 = new FileInputStream(\"\")) {" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
46 |
" try (@TB InputStream is2 = new FileInputStream(\"\")) {}" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
47 |
" }" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
48 |
"}"; |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
49 |
} |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
50 |
|
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
51 |
@TADescription(annotation = "RTAs", type = RESOURCE_VARIABLE, |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
52 |
lvarOffset = {10}, lvarLength = {30}, lvarIndex = {1}) |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
53 |
public String testRepeatedAnnotation1() { |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
54 |
return |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
55 |
"public void f() throws IOException {" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
56 |
" try (@RTA @RTA InputStream is1 = new FileInputStream(\"\")) {}" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
57 |
"}"; |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
58 |
} |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
59 |
|
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
60 |
@TADescription(annotation = "RTAs", type = RESOURCE_VARIABLE, |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
61 |
lvarOffset = {10}, lvarLength = {30}, lvarIndex = {1}) |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
62 |
public String testRepeatedAnnotation2() { |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
63 |
return |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
64 |
"public void f() throws IOException {" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
65 |
" try (@RTAs({@RTA, @RTA}) InputStream is1 = new FileInputStream(\"\")) {}" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
66 |
"}"; |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
67 |
} |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
68 |
|
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
69 |
@TADescription(annotation = "TA", type = RESOURCE_VARIABLE, |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
70 |
lvarOffset = {10}, lvarLength = {118}, lvarIndex = {1}) |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
71 |
@TADescription(annotation = "TB", type = RESOURCE_VARIABLE, |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
72 |
lvarOffset = {22}, lvarLength = {35}, lvarIndex = {3}) |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
73 |
public String testSeveralVariablesInTryWithResources() { |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
74 |
return |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
75 |
"public void f() throws IOException {" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
76 |
" try (@TA InputStream is1 = new FileInputStream(\"\");" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
77 |
" @TB InputStream is2 = new FileInputStream(\"\")) {}" + lineSeparator() + |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
78 |
"}"; |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
79 |
} |
986d876a9121
8042451: Write tests for all possible kinds of type annotation
aeremeev
parents:
diff
changeset
|
80 |
} |