author | jlahoda |
Thu, 11 Apr 2019 17:55:18 +0200 | |
changeset 54514 | b0651dcc8d98 |
parent 54512 | a84c46287f28 |
child 54568 | b2ed96c35687 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
54514
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2 |
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.jvm; |
|
27 |
||
28 |
import java.io.*; |
|
29 |
import java.net.URI; |
|
3782 | 30 |
import java.net.URISyntaxException; |
10 | 31 |
import java.nio.CharBuffer; |
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
42973
diff
changeset
|
32 |
import java.nio.file.ClosedFileSystemException; |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
33 |
import java.util.Arrays; |
10 | 34 |
import java.util.EnumSet; |
35 |
import java.util.HashMap; |
|
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
36 |
import java.util.HashSet; |
10 | 37 |
import java.util.Map; |
38 |
import java.util.Set; |
|
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
39 |
|
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
40 |
import javax.lang.model.element.Modifier; |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
41 |
import javax.lang.model.element.NestingKind; |
10 | 42 |
import javax.tools.JavaFileManager; |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
43 |
import javax.tools.JavaFileObject; |
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
44 |
|
48054
702043a4cdeb
8189749: Devise strategy for making source level checks more uniform
mcimadamore
parents:
47703
diff
changeset
|
45 |
import com.sun.tools.javac.code.Source.Feature; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
46 |
import com.sun.tools.javac.comp.Annotate; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
47 |
import com.sun.tools.javac.comp.Annotate.AnnotationTypeCompleter; |
10 | 48 |
import com.sun.tools.javac.code.*; |
36526 | 49 |
import com.sun.tools.javac.code.Directive.*; |
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
50 |
import com.sun.tools.javac.code.Lint.LintCategory; |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
51 |
import com.sun.tools.javac.code.Scope.WriteableScope; |
10 | 52 |
import com.sun.tools.javac.code.Symbol.*; |
53 |
import com.sun.tools.javac.code.Symtab; |
|
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
54 |
import com.sun.tools.javac.code.Type.*; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
55 |
import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata; |
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
56 |
import com.sun.tools.javac.file.BaseFileManager; |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
57 |
import com.sun.tools.javac.file.PathFileObject; |
27852
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
58 |
import com.sun.tools.javac.jvm.ClassFile.NameAndType; |
2e6ad0e4fe20
8061876: replace java.io.File with java.nio.file.Path (again)
jjg
parents:
27226
diff
changeset
|
59 |
import com.sun.tools.javac.jvm.ClassFile.Version; |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39587
diff
changeset
|
60 |
import com.sun.tools.javac.main.Option; |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
61 |
import com.sun.tools.javac.resources.CompilerProperties.Fragments; |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
62 |
import com.sun.tools.javac.resources.CompilerProperties.Warnings; |
10 | 63 |
import com.sun.tools.javac.util.*; |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
64 |
import com.sun.tools.javac.util.DefinedBy.Api; |
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
65 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
10 | 66 |
|
67 |
import static com.sun.tools.javac.code.Flags.*; |
|
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26781
diff
changeset
|
68 |
import static com.sun.tools.javac.code.Kinds.Kind.*; |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
69 |
|
41991
cc8a2784dd4c
8166700: NPE during invoking getEnclosedElements() on javax.lang.model.element.Element instance representing a package
jlahoda
parents:
41935
diff
changeset
|
70 |
import com.sun.tools.javac.code.Scope.LookupKind; |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
71 |
|
29551
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
72 |
import static com.sun.tools.javac.code.TypeTag.ARRAY; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13689
diff
changeset
|
73 |
import static com.sun.tools.javac.code.TypeTag.CLASS; |
20242
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
19921
diff
changeset
|
74 |
import static com.sun.tools.javac.code.TypeTag.TYPEVAR; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
75 |
import static com.sun.tools.javac.jvm.ClassFile.*; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
76 |
import static com.sun.tools.javac.jvm.ClassFile.Version.*; |
10 | 77 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39587
diff
changeset
|
78 |
import static com.sun.tools.javac.main.Option.PARAMETERS; |
6721 | 79 |
|
10 | 80 |
/** This class provides operations to read a classfile into an internal |
81 |
* representation. The internal representation is anchored in a |
|
82 |
* ClassSymbol which contains in its scope symbol representations |
|
83 |
* for all other definitions in the classfile. Top-level Classes themselves |
|
84 |
* appear as members of the scopes of PackageSymbols. |
|
85 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
86 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
87 |
* If you write code that depends on this, you do so at your own risk. |
10 | 88 |
* This code and its internal interfaces are subject to change or |
89 |
* deletion without notice.</b> |
|
90 |
*/ |
|
19921
58bcbe156057
8023974: Drop 'implements Completer' and 'implements SourceCompleter' from ClassReader resp. JavaCompiler.
jfranck
parents:
19915
diff
changeset
|
91 |
public class ClassReader { |
10 | 92 |
/** The context key for the class reader. */ |
22163 | 93 |
protected static final Context.Key<ClassReader> classReaderKey = new Context.Key<>(); |
10 | 94 |
|
7842 | 95 |
public static final int INITIAL_BUFFER_SIZE = 0x0fff0; |
96 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
97 |
private final Annotate annotate; |
10 | 98 |
|
99 |
/** Switch: verbose output. |
|
100 |
*/ |
|
101 |
boolean verbose; |
|
102 |
||
103 |
/** Switch: read constant pool and code sections. This switch is initially |
|
104 |
* set to false but can be turned on from outside. |
|
105 |
*/ |
|
106 |
public boolean readAllOfClassFile = false; |
|
107 |
||
36526 | 108 |
/** Switch: allow modules. |
109 |
*/ |
|
110 |
boolean allowModules; |
|
111 |
||
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
112 |
/** Lint option: warn about classfile issues |
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
113 |
*/ |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
114 |
boolean lintClassfile; |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
115 |
|
10 | 116 |
/** Switch: preserve parameter names from the variable table. |
117 |
*/ |
|
118 |
public boolean saveParameterNames; |
|
119 |
||
120 |
/** |
|
15724 | 121 |
* The currently selected profile. |
122 |
*/ |
|
123 |
public final Profile profile; |
|
124 |
||
10 | 125 |
/** The log to use for verbose output |
126 |
*/ |
|
127 |
final Log log; |
|
128 |
||
129 |
/** The symbol table. */ |
|
130 |
Symtab syms; |
|
131 |
||
132 |
Types types; |
|
133 |
||
134 |
/** The name table. */ |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
939
diff
changeset
|
135 |
final Names names; |
10 | 136 |
|
137 |
/** Access to files |
|
138 |
*/ |
|
139 |
private final JavaFileManager fileManager; |
|
140 |
||
169 | 141 |
/** Factory for diagnostics |
142 |
*/ |
|
143 |
JCDiagnostic.Factory diagFactory; |
|
144 |
||
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
145 |
DeferredCompletionFailureHandler dcfh; |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
146 |
|
49580
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
147 |
/** |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
148 |
* Support for preview language features. |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
149 |
*/ |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
150 |
Preview preview; |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
151 |
|
10 | 152 |
/** The current scope where type variables are entered. |
153 |
*/ |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
154 |
protected WriteableScope typevars; |
10 | 155 |
|
36526 | 156 |
private List<InterimUsesDirective> interimUses = List.nil(); |
157 |
private List<InterimProvidesDirective> interimProvides = List.nil(); |
|
158 |
||
10 | 159 |
/** The path name of the class file currently being read. |
160 |
*/ |
|
161 |
protected JavaFileObject currentClassFile = null; |
|
162 |
||
163 |
/** The class or method currently being read. |
|
164 |
*/ |
|
165 |
protected Symbol currentOwner = null; |
|
166 |
||
36526 | 167 |
/** The module containing the class currently being read. |
168 |
*/ |
|
169 |
protected ModuleSymbol currentModule = null; |
|
170 |
||
10 | 171 |
/** The buffer containing the currently read class file. |
172 |
*/ |
|
7842 | 173 |
byte[] buf = new byte[INITIAL_BUFFER_SIZE]; |
10 | 174 |
|
175 |
/** The current input pointer. |
|
176 |
*/ |
|
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
177 |
protected int bp; |
10 | 178 |
|
179 |
/** The objects of the constant pool. |
|
180 |
*/ |
|
181 |
Object[] poolObj; |
|
182 |
||
183 |
/** For every constant pool entry, an index into buf where the |
|
184 |
* defining section of the entry is found. |
|
185 |
*/ |
|
186 |
int[] poolIdx; |
|
187 |
||
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
188 |
/** The major version number of the class file being read. */ |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
189 |
int majorVersion; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
190 |
/** The minor version number of the class file being read. */ |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
191 |
int minorVersion; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
192 |
|
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
193 |
/** A table to hold the constant pool indices for method parameter |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
194 |
* names, as given in LocalVariableTable attributes. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
195 |
*/ |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
196 |
int[] parameterNameIndices; |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
197 |
|
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
198 |
/** |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
199 |
* A table to hold annotations for method parameters. |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
200 |
*/ |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
201 |
ParameterAnnotations[] parameterAnnotations; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
202 |
|
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
203 |
/** |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
204 |
* A holder for parameter annotations. |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
205 |
*/ |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
206 |
static class ParameterAnnotations { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
207 |
List<CompoundAnnotationProxy> proxies; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
208 |
|
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
209 |
void add(List<CompoundAnnotationProxy> newAnnotations) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
210 |
if (proxies == null) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
211 |
proxies = newAnnotations; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
212 |
} else { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
213 |
proxies = proxies.prependList(newAnnotations); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
214 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
215 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
216 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
217 |
|
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
218 |
/** |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
219 |
* Whether or not any parameter names have been found. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
220 |
*/ |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
221 |
boolean haveParameterNameIndices; |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
222 |
|
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
223 |
/** Set this to false every time we start reading a method |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
224 |
* and are saving parameter names. Set it to true when we see |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
225 |
* MethodParameters, if it's set when we see a LocalVariableTable, |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
226 |
* then we ignore the parameter names from the LVT. |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
227 |
*/ |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
228 |
boolean sawMethodParameters; |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
229 |
|
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
230 |
/** |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
231 |
* The set of attribute names for which warnings have been generated for the current class |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
232 |
*/ |
22163 | 233 |
Set<Name> warnedAttrs = new HashSet<>(); |
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
234 |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
235 |
/** |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
236 |
* The prototype @Target Attribute.Compound if this class is an annotation annotated with |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
237 |
* @Target |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
238 |
*/ |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
239 |
CompoundAnnotationProxy target; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
240 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
241 |
/** |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
242 |
* The prototype @Repetable Attribute.Compound if this class is an annotation annotated with |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
243 |
* @Repeatable |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
244 |
*/ |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
245 |
CompoundAnnotationProxy repeatable; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
246 |
|
10 | 247 |
/** Get the ClassReader instance for this invocation. */ |
248 |
public static ClassReader instance(Context context) { |
|
249 |
ClassReader instance = context.get(classReaderKey); |
|
250 |
if (instance == null) |
|
22442
8fd30fc4e3a3
8029690: Move symbol creation from ClassReader to Symtab
jfranck
parents:
22167
diff
changeset
|
251 |
instance = new ClassReader(context); |
10 | 252 |
return instance; |
253 |
} |
|
254 |
||
22442
8fd30fc4e3a3
8029690: Move symbol creation from ClassReader to Symtab
jfranck
parents:
22167
diff
changeset
|
255 |
/** Construct a new class reader. */ |
8fd30fc4e3a3
8029690: Move symbol creation from ClassReader to Symtab
jfranck
parents:
22167
diff
changeset
|
256 |
protected ClassReader(Context context) { |
8fd30fc4e3a3
8029690: Move symbol creation from ClassReader to Symtab
jfranck
parents:
22167
diff
changeset
|
257 |
context.put(classReaderKey, this); |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
258 |
annotate = Annotate.instance(context); |
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
939
diff
changeset
|
259 |
names = Names.instance(context); |
10 | 260 |
syms = Symtab.instance(context); |
261 |
types = Types.instance(context); |
|
262 |
fileManager = context.get(JavaFileManager.class); |
|
263 |
if (fileManager == null) |
|
264 |
throw new AssertionError("FileManager initialization error"); |
|
169 | 265 |
diagFactory = JCDiagnostic.Factory.instance(context); |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
266 |
dcfh = DeferredCompletionFailureHandler.instance(context); |
10 | 267 |
|
268 |
log = Log.instance(context); |
|
269 |
||
270 |
Options options = Options.instance(context); |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39587
diff
changeset
|
271 |
verbose = options.isSet(Option.VERBOSE); |
15724 | 272 |
|
10 | 273 |
Source source = Source.instance(context); |
49580
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
274 |
preview = Preview.instance(context); |
48054
702043a4cdeb
8189749: Devise strategy for making source level checks more uniform
mcimadamore
parents:
47703
diff
changeset
|
275 |
allowModules = Feature.MODULES.allowedInSource(source); |
15724 | 276 |
|
39587 | 277 |
saveParameterNames = options.isSet(PARAMETERS); |
10 | 278 |
|
15724 | 279 |
profile = Profile.instance(context); |
280 |
||
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
281 |
typevars = WriteableScope.create(syms.noSymbol); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
282 |
|
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
283 |
lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE); |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
284 |
|
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
285 |
initAttributeReaders(); |
10 | 286 |
} |
287 |
||
288 |
/** Add member to class unless it is synthetic. |
|
289 |
*/ |
|
290 |
private void enterMember(ClassSymbol c, Symbol sym) { |
|
16300 | 291 |
// Synthetic members are not entered -- reason lost to history (optimization?). |
292 |
// Lambda methods must be entered because they may have inner classes (which reference them) |
|
293 |
if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC || sym.name.startsWith(names.lambda)) |
|
10 | 294 |
c.members_field.enter(sym); |
295 |
} |
|
296 |
||
297 |
/************************************************************************ |
|
298 |
* Error Diagnoses |
|
299 |
***********************************************************************/ |
|
300 |
||
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
301 |
public ClassFinder.BadClassFile badClassFile(String key, Object... args) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
302 |
return new ClassFinder.BadClassFile ( |
10 | 303 |
currentOwner.enclClass(), |
304 |
currentClassFile, |
|
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
305 |
diagFactory.fragment(key, args), |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
306 |
diagFactory, |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
307 |
dcfh); |
10 | 308 |
} |
309 |
||
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
310 |
public ClassFinder.BadEnclosingMethodAttr badEnclosingMethod(Symbol sym) { |
37001
594b4565d8a4
8151191: javac error when running javadoc on some inner classes
vromero
parents:
36526
diff
changeset
|
311 |
return new ClassFinder.BadEnclosingMethodAttr ( |
594b4565d8a4
8151191: javac error when running javadoc on some inner classes
vromero
parents:
36526
diff
changeset
|
312 |
currentOwner.enclClass(), |
594b4565d8a4
8151191: javac error when running javadoc on some inner classes
vromero
parents:
36526
diff
changeset
|
313 |
currentClassFile, |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
314 |
diagFactory.fragment(Fragments.BadEnclosingMethod(sym)), |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
315 |
diagFactory, |
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
316 |
dcfh); |
37001
594b4565d8a4
8151191: javac error when running javadoc on some inner classes
vromero
parents:
36526
diff
changeset
|
317 |
} |
594b4565d8a4
8151191: javac error when running javadoc on some inner classes
vromero
parents:
36526
diff
changeset
|
318 |
|
10 | 319 |
/************************************************************************ |
320 |
* Buffer Access |
|
321 |
***********************************************************************/ |
|
322 |
||
323 |
/** Read a character. |
|
324 |
*/ |
|
325 |
char nextChar() { |
|
326 |
return (char)(((buf[bp++] & 0xFF) << 8) + (buf[bp++] & 0xFF)); |
|
327 |
} |
|
328 |
||
3149 | 329 |
/** Read a byte. |
330 |
*/ |
|
15385 | 331 |
int nextByte() { |
332 |
return buf[bp++] & 0xFF; |
|
3149 | 333 |
} |
334 |
||
10 | 335 |
/** Read an integer. |
336 |
*/ |
|
337 |
int nextInt() { |
|
338 |
return |
|
339 |
((buf[bp++] & 0xFF) << 24) + |
|
340 |
((buf[bp++] & 0xFF) << 16) + |
|
341 |
((buf[bp++] & 0xFF) << 8) + |
|
342 |
(buf[bp++] & 0xFF); |
|
343 |
} |
|
344 |
||
345 |
/** Extract a character at position bp from buf. |
|
346 |
*/ |
|
347 |
char getChar(int bp) { |
|
348 |
return |
|
349 |
(char)(((buf[bp] & 0xFF) << 8) + (buf[bp+1] & 0xFF)); |
|
350 |
} |
|
351 |
||
352 |
/** Extract an integer at position bp from buf. |
|
353 |
*/ |
|
354 |
int getInt(int bp) { |
|
355 |
return |
|
356 |
((buf[bp] & 0xFF) << 24) + |
|
357 |
((buf[bp+1] & 0xFF) << 16) + |
|
358 |
((buf[bp+2] & 0xFF) << 8) + |
|
359 |
(buf[bp+3] & 0xFF); |
|
360 |
} |
|
361 |
||
362 |
||
363 |
/** Extract a long integer at position bp from buf. |
|
364 |
*/ |
|
365 |
long getLong(int bp) { |
|
366 |
DataInputStream bufin = |
|
367 |
new DataInputStream(new ByteArrayInputStream(buf, bp, 8)); |
|
368 |
try { |
|
369 |
return bufin.readLong(); |
|
370 |
} catch (IOException e) { |
|
371 |
throw new AssertionError(e); |
|
372 |
} |
|
373 |
} |
|
374 |
||
375 |
/** Extract a float at position bp from buf. |
|
376 |
*/ |
|
377 |
float getFloat(int bp) { |
|
378 |
DataInputStream bufin = |
|
379 |
new DataInputStream(new ByteArrayInputStream(buf, bp, 4)); |
|
380 |
try { |
|
381 |
return bufin.readFloat(); |
|
382 |
} catch (IOException e) { |
|
383 |
throw new AssertionError(e); |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
/** Extract a double at position bp from buf. |
|
388 |
*/ |
|
389 |
double getDouble(int bp) { |
|
390 |
DataInputStream bufin = |
|
391 |
new DataInputStream(new ByteArrayInputStream(buf, bp, 8)); |
|
392 |
try { |
|
393 |
return bufin.readDouble(); |
|
394 |
} catch (IOException e) { |
|
395 |
throw new AssertionError(e); |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
/************************************************************************ |
|
400 |
* Constant Pool Access |
|
401 |
***********************************************************************/ |
|
402 |
||
403 |
/** Index all constant pool entries, writing their start addresses into |
|
404 |
* poolIdx. |
|
405 |
*/ |
|
406 |
void indexPool() { |
|
407 |
poolIdx = new int[nextChar()]; |
|
408 |
poolObj = new Object[poolIdx.length]; |
|
409 |
int i = 1; |
|
410 |
while (i < poolIdx.length) { |
|
411 |
poolIdx[i++] = bp; |
|
412 |
byte tag = buf[bp++]; |
|
413 |
switch (tag) { |
|
414 |
case CONSTANT_Utf8: case CONSTANT_Unicode: { |
|
415 |
int len = nextChar(); |
|
416 |
bp = bp + len; |
|
417 |
break; |
|
418 |
} |
|
419 |
case CONSTANT_Class: |
|
420 |
case CONSTANT_String: |
|
8042 | 421 |
case CONSTANT_MethodType: |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
422 |
case CONSTANT_Module: |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
423 |
case CONSTANT_Package: |
10 | 424 |
bp = bp + 2; |
425 |
break; |
|
8042 | 426 |
case CONSTANT_MethodHandle: |
427 |
bp = bp + 3; |
|
428 |
break; |
|
10 | 429 |
case CONSTANT_Fieldref: |
430 |
case CONSTANT_Methodref: |
|
431 |
case CONSTANT_InterfaceMethodref: |
|
432 |
case CONSTANT_NameandType: |
|
433 |
case CONSTANT_Integer: |
|
434 |
case CONSTANT_Float: |
|
48826 | 435 |
case CONSTANT_Dynamic: |
8042 | 436 |
case CONSTANT_InvokeDynamic: |
10 | 437 |
bp = bp + 4; |
438 |
break; |
|
439 |
case CONSTANT_Long: |
|
440 |
case CONSTANT_Double: |
|
441 |
bp = bp + 8; |
|
442 |
i++; |
|
443 |
break; |
|
444 |
default: |
|
445 |
throw badClassFile("bad.const.pool.tag.at", |
|
446 |
Byte.toString(tag), |
|
447 |
Integer.toString(bp -1)); |
|
448 |
} |
|
449 |
} |
|
450 |
} |
|
451 |
||
452 |
/** Read constant pool entry at start address i, use pool as a cache. |
|
453 |
*/ |
|
454 |
Object readPool(int i) { |
|
455 |
Object result = poolObj[i]; |
|
456 |
if (result != null) return result; |
|
457 |
||
458 |
int index = poolIdx[i]; |
|
459 |
if (index == 0) return null; |
|
460 |
||
461 |
byte tag = buf[index]; |
|
462 |
switch (tag) { |
|
463 |
case CONSTANT_Utf8: |
|
464 |
poolObj[i] = names.fromUtf(buf, index + 3, getChar(index + 1)); |
|
465 |
break; |
|
466 |
case CONSTANT_Unicode: |
|
467 |
throw badClassFile("unicode.str.not.supported"); |
|
468 |
case CONSTANT_Class: |
|
469 |
poolObj[i] = readClassOrType(getChar(index + 1)); |
|
470 |
break; |
|
471 |
case CONSTANT_String: |
|
472 |
// FIXME: (footprint) do not use toString here |
|
473 |
poolObj[i] = readName(getChar(index + 1)).toString(); |
|
474 |
break; |
|
475 |
case CONSTANT_Fieldref: { |
|
476 |
ClassSymbol owner = readClassSymbol(getChar(index + 1)); |
|
24068 | 477 |
NameAndType nt = readNameAndType(getChar(index + 3)); |
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
478 |
poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner); |
10 | 479 |
break; |
480 |
} |
|
481 |
case CONSTANT_Methodref: |
|
482 |
case CONSTANT_InterfaceMethodref: { |
|
483 |
ClassSymbol owner = readClassSymbol(getChar(index + 1)); |
|
24068 | 484 |
NameAndType nt = readNameAndType(getChar(index + 3)); |
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
485 |
poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner); |
10 | 486 |
break; |
487 |
} |
|
488 |
case CONSTANT_NameandType: |
|
489 |
poolObj[i] = new NameAndType( |
|
490 |
readName(getChar(index + 1)), |
|
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
491 |
readType(getChar(index + 3)), types); |
10 | 492 |
break; |
493 |
case CONSTANT_Integer: |
|
494 |
poolObj[i] = getInt(index + 1); |
|
495 |
break; |
|
496 |
case CONSTANT_Float: |
|
37635
9834489579e5
8145468: update java.lang APIs with new deprecations
smarks
parents:
37001
diff
changeset
|
497 |
poolObj[i] = Float.valueOf(getFloat(index + 1)); |
10 | 498 |
break; |
499 |
case CONSTANT_Long: |
|
37635
9834489579e5
8145468: update java.lang APIs with new deprecations
smarks
parents:
37001
diff
changeset
|
500 |
poolObj[i] = Long.valueOf(getLong(index + 1)); |
10 | 501 |
break; |
502 |
case CONSTANT_Double: |
|
37635
9834489579e5
8145468: update java.lang APIs with new deprecations
smarks
parents:
37001
diff
changeset
|
503 |
poolObj[i] = Double.valueOf(getDouble(index + 1)); |
10 | 504 |
break; |
8042 | 505 |
case CONSTANT_MethodHandle: |
506 |
skipBytes(4); |
|
507 |
break; |
|
508 |
case CONSTANT_MethodType: |
|
509 |
skipBytes(3); |
|
510 |
break; |
|
48826 | 511 |
case CONSTANT_Dynamic: |
8042 | 512 |
case CONSTANT_InvokeDynamic: |
513 |
skipBytes(5); |
|
514 |
break; |
|
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
515 |
case CONSTANT_Module: |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
516 |
case CONSTANT_Package: |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
517 |
// this is temporary for now: treat as a simple reference to the underlying Utf8. |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
518 |
poolObj[i] = readName(getChar(index + 1)); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
519 |
break; |
10 | 520 |
default: |
521 |
throw badClassFile("bad.const.pool.tag", Byte.toString(tag)); |
|
522 |
} |
|
523 |
return poolObj[i]; |
|
524 |
} |
|
525 |
||
526 |
/** Read signature and convert to type. |
|
527 |
*/ |
|
528 |
Type readType(int i) { |
|
529 |
int index = poolIdx[i]; |
|
530 |
return sigToType(buf, index + 3, getChar(index + 1)); |
|
531 |
} |
|
532 |
||
533 |
/** If name is an array type or class signature, return the |
|
534 |
* corresponding type; otherwise return a ClassSymbol with given name. |
|
535 |
*/ |
|
536 |
Object readClassOrType(int i) { |
|
537 |
int index = poolIdx[i]; |
|
538 |
int len = getChar(index + 1); |
|
539 |
int start = index + 3; |
|
8032 | 540 |
Assert.check(buf[start] == '[' || buf[start + len - 1] != ';'); |
10 | 541 |
// by the above assertion, the following test can be |
542 |
// simplified to (buf[start] == '[') |
|
543 |
return (buf[start] == '[' || buf[start + len - 1] == ';') |
|
544 |
? (Object)sigToType(buf, start, len) |
|
36526 | 545 |
: (Object)enterClass(names.fromUtf(internalize(buf, start, |
10 | 546 |
len))); |
547 |
} |
|
548 |
||
549 |
/** Read signature and convert to type parameters. |
|
550 |
*/ |
|
551 |
List<Type> readTypeParams(int i) { |
|
552 |
int index = poolIdx[i]; |
|
553 |
return sigToTypeParams(buf, index + 3, getChar(index + 1)); |
|
554 |
} |
|
555 |
||
556 |
/** Read class entry. |
|
557 |
*/ |
|
558 |
ClassSymbol readClassSymbol(int i) { |
|
24068 | 559 |
Object obj = readPool(i); |
560 |
if (obj != null && !(obj instanceof ClassSymbol)) |
|
561 |
throw badClassFile("bad.const.pool.entry", |
|
562 |
currentClassFile.toString(), |
|
563 |
"CONSTANT_Class_info", i); |
|
564 |
return (ClassSymbol)obj; |
|
10 | 565 |
} |
566 |
||
36526 | 567 |
Name readClassName(int i) { |
568 |
int index = poolIdx[i]; |
|
569 |
if (index == 0) return null; |
|
570 |
byte tag = buf[index]; |
|
571 |
if (tag != CONSTANT_Class) { |
|
572 |
throw badClassFile("bad.const.pool.entry", |
|
573 |
currentClassFile.toString(), |
|
574 |
"CONSTANT_Class_info", i); |
|
575 |
} |
|
576 |
int nameIndex = poolIdx[getChar(index + 1)]; |
|
577 |
int len = getChar(nameIndex + 1); |
|
578 |
int start = nameIndex + 3; |
|
579 |
if (buf[start] == '[' || buf[start + len - 1] == ';') |
|
580 |
throw badClassFile("wrong class name"); //TODO: proper diagnostics |
|
581 |
return names.fromUtf(internalize(buf, start, len)); |
|
582 |
} |
|
583 |
||
10 | 584 |
/** Read name. |
585 |
*/ |
|
586 |
Name readName(int i) { |
|
24068 | 587 |
Object obj = readPool(i); |
588 |
if (obj != null && !(obj instanceof Name)) |
|
589 |
throw badClassFile("bad.const.pool.entry", |
|
590 |
currentClassFile.toString(), |
|
591 |
"CONSTANT_Utf8_info or CONSTANT_String_info", i); |
|
592 |
return (Name)obj; |
|
593 |
} |
|
594 |
||
595 |
/** Read name and type. |
|
596 |
*/ |
|
597 |
NameAndType readNameAndType(int i) { |
|
598 |
Object obj = readPool(i); |
|
599 |
if (obj != null && !(obj instanceof NameAndType)) |
|
600 |
throw badClassFile("bad.const.pool.entry", |
|
601 |
currentClassFile.toString(), |
|
602 |
"CONSTANT_NameAndType_info", i); |
|
603 |
return (NameAndType)obj; |
|
10 | 604 |
} |
605 |
||
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
606 |
/** Read the name of a module. |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
607 |
* The name is stored in a CONSTANT_Module entry, in |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
608 |
* JVMS 4.2 binary form (using ".", not "/") |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
609 |
*/ |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
610 |
Name readModuleName(int i) { |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
611 |
return readName(i); |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
612 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
613 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
614 |
/** Read module_flags. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
615 |
*/ |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
616 |
Set<ModuleFlags> readModuleFlags(int flags) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
617 |
Set<ModuleFlags> set = EnumSet.noneOf(ModuleFlags.class); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
618 |
for (ModuleFlags f : ModuleFlags.values()) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
619 |
if ((flags & f.value) != 0) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
620 |
set.add(f); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
621 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
622 |
return set; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
623 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
624 |
|
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
625 |
/** Read resolution_flags. |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
626 |
*/ |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
627 |
Set<ModuleResolutionFlags> readModuleResolutionFlags(int flags) { |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
628 |
Set<ModuleResolutionFlags> set = EnumSet.noneOf(ModuleResolutionFlags.class); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
629 |
for (ModuleResolutionFlags f : ModuleResolutionFlags.values()) { |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
630 |
if ((flags & f.value) != 0) |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
631 |
set.add(f); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
632 |
} |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
633 |
return set; |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
634 |
} |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
635 |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
636 |
/** Read exports_flags. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
637 |
*/ |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
638 |
Set<ExportsFlag> readExportsFlags(int flags) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
639 |
Set<ExportsFlag> set = EnumSet.noneOf(ExportsFlag.class); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
640 |
for (ExportsFlag f: ExportsFlag.values()) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
641 |
if ((flags & f.value) != 0) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
642 |
set.add(f); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
643 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
644 |
return set; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
645 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
646 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
647 |
/** Read opens_flags. |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
648 |
*/ |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
649 |
Set<OpensFlag> readOpensFlags(int flags) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
650 |
Set<OpensFlag> set = EnumSet.noneOf(OpensFlag.class); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
651 |
for (OpensFlag f: OpensFlag.values()) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
652 |
if ((flags & f.value) != 0) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
653 |
set.add(f); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
654 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
655 |
return set; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
656 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
657 |
|
36526 | 658 |
/** Read requires_flags. |
659 |
*/ |
|
660 |
Set<RequiresFlag> readRequiresFlags(int flags) { |
|
661 |
Set<RequiresFlag> set = EnumSet.noneOf(RequiresFlag.class); |
|
662 |
for (RequiresFlag f: RequiresFlag.values()) { |
|
663 |
if ((flags & f.value) != 0) |
|
664 |
set.add(f); |
|
665 |
} |
|
666 |
return set; |
|
667 |
} |
|
668 |
||
10 | 669 |
/************************************************************************ |
670 |
* Reading Types |
|
671 |
***********************************************************************/ |
|
672 |
||
673 |
/** The unread portion of the currently read type is |
|
674 |
* signature[sigp..siglimit-1]. |
|
675 |
*/ |
|
676 |
byte[] signature; |
|
677 |
int sigp; |
|
678 |
int siglimit; |
|
679 |
boolean sigEnterPhase = false; |
|
680 |
||
681 |
/** Convert signature to type, where signature is a byte array segment. |
|
682 |
*/ |
|
683 |
Type sigToType(byte[] sig, int offset, int len) { |
|
684 |
signature = sig; |
|
685 |
sigp = offset; |
|
686 |
siglimit = offset + len; |
|
687 |
return sigToType(); |
|
688 |
} |
|
689 |
||
690 |
/** Convert signature to type, where signature is implicit. |
|
691 |
*/ |
|
692 |
Type sigToType() { |
|
693 |
switch ((char) signature[sigp]) { |
|
694 |
case 'T': |
|
695 |
sigp++; |
|
696 |
int start = sigp; |
|
697 |
while (signature[sigp] != ';') sigp++; |
|
698 |
sigp++; |
|
699 |
return sigEnterPhase |
|
700 |
? Type.noType |
|
701 |
: findTypeVar(names.fromUtf(signature, start, sigp - 1 - start)); |
|
702 |
case '+': { |
|
703 |
sigp++; |
|
704 |
Type t = sigToType(); |
|
26781
a786b07c7b91
8048614: Add TypeMetadata to contain type annotations and other type information
emc
parents:
26532
diff
changeset
|
705 |
return new WildcardType(t, BoundKind.EXTENDS, syms.boundClass); |
10 | 706 |
} |
707 |
case '*': |
|
708 |
sigp++; |
|
709 |
return new WildcardType(syms.objectType, BoundKind.UNBOUND, |
|
26781
a786b07c7b91
8048614: Add TypeMetadata to contain type annotations and other type information
emc
parents:
26532
diff
changeset
|
710 |
syms.boundClass); |
10 | 711 |
case '-': { |
712 |
sigp++; |
|
713 |
Type t = sigToType(); |
|
26781
a786b07c7b91
8048614: Add TypeMetadata to contain type annotations and other type information
emc
parents:
26532
diff
changeset
|
714 |
return new WildcardType(t, BoundKind.SUPER, syms.boundClass); |
10 | 715 |
} |
716 |
case 'B': |
|
717 |
sigp++; |
|
718 |
return syms.byteType; |
|
719 |
case 'C': |
|
720 |
sigp++; |
|
721 |
return syms.charType; |
|
722 |
case 'D': |
|
723 |
sigp++; |
|
724 |
return syms.doubleType; |
|
725 |
case 'F': |
|
726 |
sigp++; |
|
727 |
return syms.floatType; |
|
728 |
case 'I': |
|
729 |
sigp++; |
|
730 |
return syms.intType; |
|
731 |
case 'J': |
|
732 |
sigp++; |
|
733 |
return syms.longType; |
|
734 |
case 'L': |
|
735 |
{ |
|
736 |
// int oldsigp = sigp; |
|
737 |
Type t = classSigToType(); |
|
738 |
if (sigp < siglimit && signature[sigp] == '.') |
|
739 |
throw badClassFile("deprecated inner class signature syntax " + |
|
740 |
"(please recompile from source)"); |
|
741 |
/* |
|
742 |
System.err.println(" decoded " + |
|
743 |
new String(signature, oldsigp, sigp-oldsigp) + |
|
744 |
" => " + t + " outer " + t.outer()); |
|
745 |
*/ |
|
746 |
return t; |
|
747 |
} |
|
748 |
case 'S': |
|
749 |
sigp++; |
|
750 |
return syms.shortType; |
|
751 |
case 'V': |
|
752 |
sigp++; |
|
753 |
return syms.voidType; |
|
754 |
case 'Z': |
|
755 |
sigp++; |
|
756 |
return syms.booleanType; |
|
757 |
case '[': |
|
758 |
sigp++; |
|
26781
a786b07c7b91
8048614: Add TypeMetadata to contain type annotations and other type information
emc
parents:
26532
diff
changeset
|
759 |
return new ArrayType(sigToType(), syms.arrayClass); |
10 | 760 |
case '(': |
761 |
sigp++; |
|
762 |
List<Type> argtypes = sigToTypes(')'); |
|
763 |
Type restype = sigToType(); |
|
764 |
List<Type> thrown = List.nil(); |
|
765 |
while (signature[sigp] == '^') { |
|
766 |
sigp++; |
|
767 |
thrown = thrown.prepend(sigToType()); |
|
768 |
} |
|
20242
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
19921
diff
changeset
|
769 |
// if there is a typevar in the throws clause we should state it. |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
19921
diff
changeset
|
770 |
for (List<Type> l = thrown; l.nonEmpty(); l = l.tail) { |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
19921
diff
changeset
|
771 |
if (l.head.hasTag(TYPEVAR)) { |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
19921
diff
changeset
|
772 |
l.head.tsym.flags_field |= THROWS; |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
19921
diff
changeset
|
773 |
} |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
19921
diff
changeset
|
774 |
} |
10 | 775 |
return new MethodType(argtypes, |
776 |
restype, |
|
777 |
thrown.reverse(), |
|
778 |
syms.methodClass); |
|
779 |
case '<': |
|
780 |
typevars = typevars.dup(currentOwner); |
|
781 |
Type poly = new ForAll(sigToTypeParams(), sigToType()); |
|
782 |
typevars = typevars.leave(); |
|
783 |
return poly; |
|
784 |
default: |
|
785 |
throw badClassFile("bad.signature", |
|
786 |
Convert.utf2string(signature, sigp, 10)); |
|
787 |
} |
|
788 |
} |
|
789 |
||
790 |
byte[] signatureBuffer = new byte[0]; |
|
791 |
int sbp = 0; |
|
792 |
/** Convert class signature to type, where signature is implicit. |
|
793 |
*/ |
|
794 |
Type classSigToType() { |
|
795 |
if (signature[sigp] != 'L') |
|
796 |
throw badClassFile("bad.class.signature", |
|
797 |
Convert.utf2string(signature, sigp, 10)); |
|
798 |
sigp++; |
|
799 |
Type outer = Type.noType; |
|
800 |
int startSbp = sbp; |
|
801 |
||
802 |
while (true) { |
|
803 |
final byte c = signature[sigp++]; |
|
804 |
switch (c) { |
|
805 |
||
806 |
case ';': { // end |
|
36526 | 807 |
ClassSymbol t = enterClass(names.fromUtf(signatureBuffer, |
10 | 808 |
startSbp, |
809 |
sbp - startSbp)); |
|
19915
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
810 |
|
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
811 |
try { |
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
812 |
return (outer == Type.noType) ? |
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
813 |
t.erasure(types) : |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42822
diff
changeset
|
814 |
new ClassType(outer, List.nil(), t); |
19915
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
815 |
} finally { |
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
816 |
sbp = startSbp; |
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
817 |
} |
10 | 818 |
} |
819 |
||
820 |
case '<': // generic arguments |
|
36526 | 821 |
ClassSymbol t = enterClass(names.fromUtf(signatureBuffer, |
10 | 822 |
startSbp, |
823 |
sbp - startSbp)); |
|
26781
a786b07c7b91
8048614: Add TypeMetadata to contain type annotations and other type information
emc
parents:
26532
diff
changeset
|
824 |
outer = new ClassType(outer, sigToTypes('>'), t) { |
10 | 825 |
boolean completed = false; |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
826 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
10 | 827 |
public Type getEnclosingType() { |
828 |
if (!completed) { |
|
829 |
completed = true; |
|
830 |
tsym.complete(); |
|
831 |
Type enclosingType = tsym.type.getEnclosingType(); |
|
832 |
if (enclosingType != Type.noType) { |
|
833 |
List<Type> typeArgs = |
|
834 |
super.getEnclosingType().allparams(); |
|
835 |
List<Type> typeParams = |
|
836 |
enclosingType.allparams(); |
|
837 |
if (typeParams.length() != typeArgs.length()) { |
|
838 |
// no "rare" types |
|
839 |
super.setEnclosingType(types.erasure(enclosingType)); |
|
840 |
} else { |
|
841 |
super.setEnclosingType(types.subst(enclosingType, |
|
842 |
typeParams, |
|
843 |
typeArgs)); |
|
844 |
} |
|
845 |
} else { |
|
846 |
super.setEnclosingType(Type.noType); |
|
847 |
} |
|
848 |
} |
|
849 |
return super.getEnclosingType(); |
|
850 |
} |
|
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
851 |
@Override |
10 | 852 |
public void setEnclosingType(Type outer) { |
853 |
throw new UnsupportedOperationException(); |
|
854 |
} |
|
855 |
}; |
|
856 |
switch (signature[sigp++]) { |
|
857 |
case ';': |
|
858 |
if (sigp < signature.length && signature[sigp] == '.') { |
|
859 |
// support old-style GJC signatures |
|
860 |
// The signature produced was |
|
861 |
// Lfoo/Outer<Lfoo/X;>;.Lfoo/Outer$Inner<Lfoo/Y;>; |
|
862 |
// rather than say |
|
863 |
// Lfoo/Outer<Lfoo/X;>.Inner<Lfoo/Y;>; |
|
864 |
// so we skip past ".Lfoo/Outer$" |
|
865 |
sigp += (sbp - startSbp) + // "foo/Outer" |
|
866 |
3; // ".L" and "$" |
|
867 |
signatureBuffer[sbp++] = (byte)'$'; |
|
868 |
break; |
|
869 |
} else { |
|
870 |
sbp = startSbp; |
|
871 |
return outer; |
|
872 |
} |
|
873 |
case '.': |
|
874 |
signatureBuffer[sbp++] = (byte)'$'; |
|
875 |
break; |
|
876 |
default: |
|
877 |
throw new AssertionError(signature[sigp-1]); |
|
878 |
} |
|
879 |
continue; |
|
880 |
||
881 |
case '.': |
|
19915
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
882 |
//we have seen an enclosing non-generic class |
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
883 |
if (outer != Type.noType) { |
36526 | 884 |
t = enterClass(names.fromUtf(signatureBuffer, |
19915
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
885 |
startSbp, |
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
886 |
sbp - startSbp)); |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42822
diff
changeset
|
887 |
outer = new ClassType(outer, List.nil(), t); |
19915
8a6dae12e4bd
8022162: Incorrect signature determination for certain inner class generics
vromero
parents:
18389
diff
changeset
|
888 |
} |
10 | 889 |
signatureBuffer[sbp++] = (byte)'$'; |
890 |
continue; |
|
891 |
case '/': |
|
892 |
signatureBuffer[sbp++] = (byte)'.'; |
|
893 |
continue; |
|
894 |
default: |
|
895 |
signatureBuffer[sbp++] = c; |
|
896 |
continue; |
|
897 |
} |
|
898 |
} |
|
899 |
} |
|
900 |
||
901 |
/** Convert (implicit) signature to list of types |
|
902 |
* until `terminator' is encountered. |
|
903 |
*/ |
|
904 |
List<Type> sigToTypes(char terminator) { |
|
905 |
List<Type> head = List.of(null); |
|
906 |
List<Type> tail = head; |
|
907 |
while (signature[sigp] != terminator) |
|
908 |
tail = tail.setTail(List.of(sigToType())); |
|
909 |
sigp++; |
|
910 |
return head.tail; |
|
911 |
} |
|
912 |
||
913 |
/** Convert signature to type parameters, where signature is a byte |
|
914 |
* array segment. |
|
915 |
*/ |
|
916 |
List<Type> sigToTypeParams(byte[] sig, int offset, int len) { |
|
917 |
signature = sig; |
|
918 |
sigp = offset; |
|
919 |
siglimit = offset + len; |
|
920 |
return sigToTypeParams(); |
|
921 |
} |
|
922 |
||
923 |
/** Convert signature to type parameters, where signature is implicit. |
|
924 |
*/ |
|
925 |
List<Type> sigToTypeParams() { |
|
926 |
List<Type> tvars = List.nil(); |
|
927 |
if (signature[sigp] == '<') { |
|
928 |
sigp++; |
|
929 |
int start = sigp; |
|
930 |
sigEnterPhase = true; |
|
931 |
while (signature[sigp] != '>') |
|
932 |
tvars = tvars.prepend(sigToTypeParam()); |
|
933 |
sigEnterPhase = false; |
|
934 |
sigp = start; |
|
935 |
while (signature[sigp] != '>') |
|
936 |
sigToTypeParam(); |
|
937 |
sigp++; |
|
938 |
} |
|
939 |
return tvars.reverse(); |
|
940 |
} |
|
941 |
||
942 |
/** Convert (implicit) signature to type parameter. |
|
943 |
*/ |
|
944 |
Type sigToTypeParam() { |
|
945 |
int start = sigp; |
|
946 |
while (signature[sigp] != ':') sigp++; |
|
947 |
Name name = names.fromUtf(signature, start, sigp - start); |
|
948 |
TypeVar tvar; |
|
949 |
if (sigEnterPhase) { |
|
26781
a786b07c7b91
8048614: Add TypeMetadata to contain type annotations and other type information
emc
parents:
26532
diff
changeset
|
950 |
tvar = new TypeVar(name, currentOwner, syms.botType); |
10 | 951 |
typevars.enter(tvar.tsym); |
952 |
} else { |
|
953 |
tvar = (TypeVar)findTypeVar(name); |
|
954 |
} |
|
955 |
List<Type> bounds = List.nil(); |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14547
diff
changeset
|
956 |
boolean allInterfaces = false; |
10 | 957 |
if (signature[sigp] == ':' && signature[sigp+1] == ':') { |
958 |
sigp++; |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14547
diff
changeset
|
959 |
allInterfaces = true; |
10 | 960 |
} |
961 |
while (signature[sigp] == ':') { |
|
962 |
sigp++; |
|
963 |
bounds = bounds.prepend(sigToType()); |
|
964 |
} |
|
965 |
if (!sigEnterPhase) { |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14547
diff
changeset
|
966 |
types.setBounds(tvar, bounds.reverse(), allInterfaces); |
10 | 967 |
} |
968 |
return tvar; |
|
969 |
} |
|
970 |
||
971 |
/** Find type variable with given name in `typevars' scope. |
|
972 |
*/ |
|
973 |
Type findTypeVar(Name name) { |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
974 |
Symbol s = typevars.findFirst(name); |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
975 |
if (s != null) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
976 |
return s.type; |
10 | 977 |
} else { |
978 |
if (readingClassAttr) { |
|
979 |
// While reading the class attribute, the supertypes |
|
980 |
// might refer to a type variable from an enclosing element |
|
981 |
// (method or class). |
|
982 |
// If the type variable is defined in the enclosing class, |
|
983 |
// we can actually find it in |
|
984 |
// currentOwner.owner.type.getTypeArguments() |
|
985 |
// However, until we have read the enclosing method attribute |
|
986 |
// we don't know for sure if this owner is correct. It could |
|
987 |
// be a method and there is no way to tell before reading the |
|
988 |
// enclosing method attribute. |
|
26781
a786b07c7b91
8048614: Add TypeMetadata to contain type annotations and other type information
emc
parents:
26532
diff
changeset
|
989 |
TypeVar t = new TypeVar(name, currentOwner, syms.botType); |
10 | 990 |
missingTypeVariables = missingTypeVariables.prepend(t); |
991 |
// System.err.println("Missing type var " + name); |
|
992 |
return t; |
|
993 |
} |
|
994 |
throw badClassFile("undecl.type.var", name); |
|
995 |
} |
|
996 |
} |
|
997 |
||
998 |
/************************************************************************ |
|
999 |
* Reading Attributes |
|
1000 |
***********************************************************************/ |
|
1001 |
||
22163 | 1002 |
protected enum AttributeKind { CLASS, MEMBER } |
1003 |
||
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1004 |
protected abstract class AttributeReader { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1005 |
protected AttributeReader(Name name, ClassFile.Version version, Set<AttributeKind> kinds) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1006 |
this.name = name; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1007 |
this.version = version; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1008 |
this.kinds = kinds; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1009 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1010 |
|
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1011 |
protected boolean accepts(AttributeKind kind) { |
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1012 |
if (kinds.contains(kind)) { |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1013 |
if (majorVersion > version.major || (majorVersion == version.major && minorVersion >= version.minor)) |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1014 |
return true; |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1015 |
|
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1016 |
if (lintClassfile && !warnedAttrs.contains(name)) { |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1017 |
JavaFileObject prev = log.useSource(currentClassFile); |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1018 |
try { |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
1019 |
log.warning(LintCategory.CLASSFILE, (DiagnosticPosition) null, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
1020 |
Warnings.FutureAttr(name, version.major, version.minor, majorVersion, minorVersion)); |
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1021 |
} finally { |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1022 |
log.useSource(prev); |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1023 |
} |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1024 |
warnedAttrs.add(name); |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1025 |
} |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1026 |
} |
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1027 |
return false; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1028 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1029 |
|
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1030 |
protected abstract void read(Symbol sym, int attrLen); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1031 |
|
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1032 |
protected final Name name; |
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1033 |
protected final ClassFile.Version version; |
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1034 |
protected final Set<AttributeKind> kinds; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1035 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1036 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1037 |
protected Set<AttributeKind> CLASS_ATTRIBUTE = |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1038 |
EnumSet.of(AttributeKind.CLASS); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1039 |
protected Set<AttributeKind> MEMBER_ATTRIBUTE = |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1040 |
EnumSet.of(AttributeKind.MEMBER); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1041 |
protected Set<AttributeKind> CLASS_OR_MEMBER_ATTRIBUTE = |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1042 |
EnumSet.of(AttributeKind.CLASS, AttributeKind.MEMBER); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1043 |
|
22163 | 1044 |
protected Map<Name, AttributeReader> attributeReaders = new HashMap<>(); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1045 |
|
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
1046 |
private void initAttributeReaders() { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1047 |
AttributeReader[] readers = { |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1048 |
// v45.3 attributes |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1049 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1050 |
new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1051 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1052 |
if (readAllOfClassFile || saveParameterNames) |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1053 |
((MethodSymbol)sym).code = readCode(sym); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1054 |
else |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1055 |
bp = bp + attrLen; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1056 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1057 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1058 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1059 |
new AttributeReader(names.ConstantValue, V45_3, MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1060 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1061 |
Object v = readPool(nextChar()); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1062 |
// Ignore ConstantValue attribute if field not final. |
42973
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1063 |
if ((sym.flags() & FINAL) == 0) { |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1064 |
return; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1065 |
} |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1066 |
VarSymbol var = (VarSymbol) sym; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1067 |
switch (var.type.getTag()) { |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1068 |
case BOOLEAN: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1069 |
case BYTE: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1070 |
case CHAR: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1071 |
case SHORT: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1072 |
case INT: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1073 |
checkType(var, Integer.class, v); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1074 |
break; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1075 |
case LONG: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1076 |
checkType(var, Long.class, v); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1077 |
break; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1078 |
case FLOAT: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1079 |
checkType(var, Float.class, v); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1080 |
break; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1081 |
case DOUBLE: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1082 |
checkType(var, Double.class, v); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1083 |
break; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1084 |
case CLASS: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1085 |
Assert.check(var.type.tsym == syms.stringType.tsym); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1086 |
checkType(var, String.class, v); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1087 |
break; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1088 |
default: |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1089 |
// ignore ConstantValue attribute if type is not primitive or String |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1090 |
return; |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1091 |
} |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1092 |
if (v instanceof Integer && !var.type.getTag().checkRange((Integer) v)) { |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1093 |
throw badClassFile("bad.constant.range", v, var, var.type); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1094 |
} |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1095 |
var.setData(v); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1096 |
} |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1097 |
|
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1098 |
void checkType(Symbol var, Class<?> clazz, Object value) { |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1099 |
if (!clazz.isInstance(value)) { |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1100 |
throw badClassFile("bad.constant.value", value, var, clazz.getSimpleName()); |
3795332b55c7
8171132: Improve class reading of invalid or out-of-range ConstantValue attributes
cushon
parents:
42828
diff
changeset
|
1101 |
} |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1102 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1103 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1104 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1105 |
new AttributeReader(names.Deprecated, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1106 |
protected void read(Symbol sym, int attrLen) { |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1107 |
Symbol s = sym.owner.kind == MDL ? sym.owner : sym; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1108 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1109 |
s.flags_field |= DEPRECATED; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1110 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1111 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1112 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1113 |
new AttributeReader(names.Exceptions, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1114 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1115 |
int nexceptions = nextChar(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1116 |
List<Type> thrown = List.nil(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1117 |
for (int j = 0; j < nexceptions; j++) |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1118 |
thrown = thrown.prepend(readClassSymbol(nextChar()).type); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1119 |
if (sym.type.getThrownTypes().isEmpty()) |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1120 |
sym.type.asMethodType().thrown = thrown.reverse(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1121 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1122 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1123 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1124 |
new AttributeReader(names.InnerClasses, V45_3, CLASS_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1125 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1126 |
ClassSymbol c = (ClassSymbol) sym; |
36526 | 1127 |
if (currentModule.module_info == c) { |
1128 |
//prevent entering the classes too soon: |
|
1129 |
skipInnerClasses(); |
|
1130 |
} else { |
|
1131 |
readInnerClasses(c); |
|
1132 |
} |
|
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1133 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1134 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1135 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1136 |
new AttributeReader(names.LocalVariableTable, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1137 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1138 |
int newbp = bp + attrLen; |
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
1139 |
if (saveParameterNames && !sawMethodParameters) { |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1140 |
// Pick up parameter names from the variable table. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1141 |
// Parameter names are not explicitly identified as such, |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1142 |
// but all parameter name entries in the LocalVariableTable |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1143 |
// have a start_pc of 0. Therefore, we record the name |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1144 |
// indicies of all slots with a start_pc of zero in the |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1145 |
// parameterNameIndicies array. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1146 |
// Note that this implicitly honors the JVMS spec that |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1147 |
// there may be more than one LocalVariableTable, and that |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1148 |
// there is no specified ordering for the entries. |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1149 |
int numEntries = nextChar(); |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1150 |
for (int i = 0; i < numEntries; i++) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1151 |
int start_pc = nextChar(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1152 |
int length = nextChar(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1153 |
int nameIndex = nextChar(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1154 |
int sigIndex = nextChar(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1155 |
int register = nextChar(); |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1156 |
if (start_pc == 0) { |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1157 |
// ensure array large enough |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1158 |
if (register >= parameterNameIndices.length) { |
39178
997c7bd366db
8136453: Parameter name indices array size not updated correctly
jlahoda
parents:
37635
diff
changeset
|
1159 |
int newSize = |
997c7bd366db
8136453: Parameter name indices array size not updated correctly
jlahoda
parents:
37635
diff
changeset
|
1160 |
Math.max(register + 1, parameterNameIndices.length + 8); |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1161 |
parameterNameIndices = |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1162 |
Arrays.copyOf(parameterNameIndices, newSize); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1163 |
} |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1164 |
parameterNameIndices[register] = nameIndex; |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
1165 |
haveParameterNameIndices = true; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1166 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1167 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1168 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1169 |
bp = newbp; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1170 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1171 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1172 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1173 |
new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1174 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1175 |
ClassSymbol c = (ClassSymbol) sym; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1176 |
Name n = readName(nextChar()); |
54039 | 1177 |
c.sourcefile = new SourceFileObject(n); |
14369
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1178 |
// If the class is a toplevel class, originating from a Java source file, |
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1179 |
// but the class name does not match the file name, then it is |
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1180 |
// an auxiliary class. |
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1181 |
String sn = n.toString(); |
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
26781
diff
changeset
|
1182 |
if (c.owner.kind == PCK && |
14369
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1183 |
sn.endsWith(".java") && |
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1184 |
!sn.equals(c.name.toString()+".java")) { |
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1185 |
c.flags_field |= AUXILIARY; |
3d660d08d1f7
7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents:
14359
diff
changeset
|
1186 |
} |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1187 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1188 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1189 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1190 |
new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1191 |
protected void read(Symbol sym, int attrLen) { |
25445
603f0c93d5c9
8011044: Remove support for 1.5 and earlier source and target options
ntoda
parents:
25443
diff
changeset
|
1192 |
sym.flags_field |= SYNTHETIC; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1193 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1194 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1195 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1196 |
// standard v49 attributes |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1197 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1198 |
new AttributeReader(names.EnclosingMethod, V49, CLASS_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1199 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1200 |
int newbp = bp + attrLen; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1201 |
readEnclosingMethodAttr(sym); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1202 |
bp = newbp; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1203 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1204 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1205 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1206 |
new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1207 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1208 |
if (sym.kind == TYP) { |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1209 |
ClassSymbol c = (ClassSymbol) sym; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1210 |
readingClassAttr = true; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1211 |
try { |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1212 |
ClassType ct1 = (ClassType)c.type; |
8032 | 1213 |
Assert.check(c == currentOwner); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1214 |
ct1.typarams_field = readTypeParams(nextChar()); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1215 |
ct1.supertype_field = sigToType(); |
22163 | 1216 |
ListBuffer<Type> is = new ListBuffer<>(); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1217 |
while (sigp != siglimit) is.append(sigToType()); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1218 |
ct1.interfaces_field = is.toList(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1219 |
} finally { |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1220 |
readingClassAttr = false; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1221 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1222 |
} else { |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1223 |
List<Type> thrown = sym.type.getThrownTypes(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1224 |
sym.type = readType(nextChar()); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1225 |
//- System.err.println(" # " + sym.type); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1226 |
if (sym.kind == MTH && sym.type.getThrownTypes().isEmpty()) |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1227 |
sym.type.asMethodType().thrown = thrown; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1228 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1229 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1230 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1231 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1232 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1233 |
// v49 annotation attributes |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1234 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1235 |
new AttributeReader(names.AnnotationDefault, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1236 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1237 |
attachAnnotationDefault(sym); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1238 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1239 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1240 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1241 |
new AttributeReader(names.RuntimeInvisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1242 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1243 |
attachAnnotations(sym); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1244 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1245 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1246 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1247 |
new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1248 |
protected void read(Symbol sym, int attrLen) { |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1249 |
readParameterAnnotations(sym); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1250 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1251 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1252 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1253 |
new AttributeReader(names.RuntimeVisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1254 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1255 |
attachAnnotations(sym); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1256 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1257 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1258 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1259 |
new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1260 |
protected void read(Symbol sym, int attrLen) { |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1261 |
readParameterAnnotations(sym); |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1262 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1263 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1264 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1265 |
// additional "legacy" v49 attributes, superceded by flags |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1266 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1267 |
new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1268 |
protected void read(Symbol sym, int attrLen) { |
25445
603f0c93d5c9
8011044: Remove support for 1.5 and earlier source and target options
ntoda
parents:
25443
diff
changeset
|
1269 |
sym.flags_field |= ANNOTATION; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1270 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1271 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1272 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1273 |
new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1274 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1275 |
sym.flags_field |= BRIDGE; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1276 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1277 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1278 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1279 |
new AttributeReader(names.Enum, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1280 |
protected void read(Symbol sym, int attrLen) { |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1281 |
sym.flags_field |= ENUM; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1282 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1283 |
}, |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1284 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1285 |
new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1286 |
protected void read(Symbol sym, int attrLen) { |
25445
603f0c93d5c9
8011044: Remove support for 1.5 and earlier source and target options
ntoda
parents:
25443
diff
changeset
|
1287 |
sym.flags_field |= VARARGS; |
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1288 |
} |
3149 | 1289 |
}, |
1290 |
||
15385 | 1291 |
new AttributeReader(names.RuntimeVisibleTypeAnnotations, V52, CLASS_OR_MEMBER_ATTRIBUTE) { |
1292 |
protected void read(Symbol sym, int attrLen) { |
|
1293 |
attachTypeAnnotations(sym); |
|
1294 |
} |
|
1295 |
}, |
|
1296 |
||
1297 |
new AttributeReader(names.RuntimeInvisibleTypeAnnotations, V52, CLASS_OR_MEMBER_ATTRIBUTE) { |
|
1298 |
protected void read(Symbol sym, int attrLen) { |
|
1299 |
attachTypeAnnotations(sym); |
|
1300 |
} |
|
1301 |
}, |
|
1302 |
||
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1303 |
// The following attributes for a Code attribute are not currently handled |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1304 |
// StackMapTable |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1305 |
// SourceDebugExtension |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1306 |
// LineNumberTable |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1307 |
// LocalVariableTypeTable |
36526 | 1308 |
|
1309 |
// standard v52 attributes |
|
1310 |
||
1311 |
new AttributeReader(names.MethodParameters, V52, MEMBER_ATTRIBUTE) { |
|
1312 |
protected void read(Symbol sym, int attrlen) { |
|
1313 |
int newbp = bp + attrlen; |
|
1314 |
if (saveParameterNames) { |
|
1315 |
sawMethodParameters = true; |
|
1316 |
int numEntries = nextByte(); |
|
1317 |
parameterNameIndices = new int[numEntries]; |
|
1318 |
haveParameterNameIndices = true; |
|
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1319 |
int index = 0; |
36526 | 1320 |
for (int i = 0; i < numEntries; i++) { |
1321 |
int nameIndex = nextChar(); |
|
1322 |
int flags = nextChar(); |
|
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1323 |
if ((flags & (Flags.MANDATED | Flags.SYNTHETIC)) != 0) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1324 |
continue; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1325 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1326 |
parameterNameIndices[index++] = nameIndex; |
36526 | 1327 |
} |
1328 |
} |
|
1329 |
bp = newbp; |
|
1330 |
} |
|
1331 |
}, |
|
1332 |
||
1333 |
// standard v53 attributes |
|
1334 |
||
1335 |
new AttributeReader(names.Module, V53, CLASS_ATTRIBUTE) { |
|
1336 |
@Override |
|
1337 |
protected boolean accepts(AttributeKind kind) { |
|
1338 |
return super.accepts(kind) && allowModules; |
|
1339 |
} |
|
1340 |
protected void read(Symbol sym, int attrLen) { |
|
1341 |
if (sym.kind == TYP && sym.owner.kind == MDL) { |
|
1342 |
ModuleSymbol msym = (ModuleSymbol) sym.owner; |
|
1343 |
ListBuffer<Directive> directives = new ListBuffer<>(); |
|
1344 |
||
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
1345 |
Name moduleName = readModuleName(nextChar()); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
1346 |
if (currentModule.name != moduleName) { |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
1347 |
throw badClassFile("module.name.mismatch", moduleName, currentModule.name); |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1348 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1349 |
|
48427
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1350 |
Set<ModuleFlags> moduleFlags = readModuleFlags(nextChar()); |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1351 |
msym.flags.addAll(moduleFlags); |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
1352 |
msym.version = readName(nextChar()); |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1353 |
|
36526 | 1354 |
ListBuffer<RequiresDirective> requires = new ListBuffer<>(); |
1355 |
int nrequires = nextChar(); |
|
1356 |
for (int i = 0; i < nrequires; i++) { |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1357 |
ModuleSymbol rsym = syms.enterModule(readModuleName(nextChar())); |
36526 | 1358 |
Set<RequiresFlag> flags = readRequiresFlags(nextChar()); |
48427
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1359 |
if (rsym == syms.java_base && majorVersion >= V54.major) { |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1360 |
if (flags.contains(RequiresFlag.TRANSITIVE)) { |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1361 |
throw badClassFile("bad.requires.flag", RequiresFlag.TRANSITIVE); |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1362 |
} |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1363 |
if (flags.contains(RequiresFlag.STATIC_PHASE)) { |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1364 |
throw badClassFile("bad.requires.flag", RequiresFlag.STATIC_PHASE); |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1365 |
} |
b08405cc467a
8193125: javac should not compile a module if it requires java.base with modifiers
jjg
parents:
48081
diff
changeset
|
1366 |
} |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
1367 |
nextChar(); // skip compiled version |
36526 | 1368 |
requires.add(new RequiresDirective(rsym, flags)); |
1369 |
} |
|
1370 |
msym.requires = requires.toList(); |
|
1371 |
directives.addAll(msym.requires); |
|
1372 |
||
1373 |
ListBuffer<ExportsDirective> exports = new ListBuffer<>(); |
|
1374 |
int nexports = nextChar(); |
|
1375 |
for (int i = 0; i < nexports; i++) { |
|
1376 |
Name n = readName(nextChar()); |
|
1377 |
PackageSymbol p = syms.enterPackage(currentModule, names.fromUtf(internalize(n))); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1378 |
Set<ExportsFlag> flags = readExportsFlags(nextChar()); |
36526 | 1379 |
int nto = nextChar(); |
1380 |
List<ModuleSymbol> to; |
|
1381 |
if (nto == 0) { |
|
1382 |
to = null; |
|
1383 |
} else { |
|
1384 |
ListBuffer<ModuleSymbol> lb = new ListBuffer<>(); |
|
1385 |
for (int t = 0; t < nto; t++) |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1386 |
lb.append(syms.enterModule(readModuleName(nextChar()))); |
36526 | 1387 |
to = lb.toList(); |
1388 |
} |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1389 |
exports.add(new ExportsDirective(p, to, flags)); |
36526 | 1390 |
} |
1391 |
msym.exports = exports.toList(); |
|
1392 |
directives.addAll(msym.exports); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1393 |
ListBuffer<OpensDirective> opens = new ListBuffer<>(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1394 |
int nopens = nextChar(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1395 |
if (nopens != 0 && msym.flags.contains(ModuleFlags.OPEN)) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1396 |
throw badClassFile("module.non.zero.opens", currentModule.name); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1397 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1398 |
for (int i = 0; i < nopens; i++) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1399 |
Name n = readName(nextChar()); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1400 |
PackageSymbol p = syms.enterPackage(currentModule, names.fromUtf(internalize(n))); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1401 |
Set<OpensFlag> flags = readOpensFlags(nextChar()); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1402 |
int nto = nextChar(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1403 |
List<ModuleSymbol> to; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1404 |
if (nto == 0) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1405 |
to = null; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1406 |
} else { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1407 |
ListBuffer<ModuleSymbol> lb = new ListBuffer<>(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1408 |
for (int t = 0; t < nto; t++) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1409 |
lb.append(syms.enterModule(readModuleName(nextChar()))); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1410 |
to = lb.toList(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1411 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1412 |
opens.add(new OpensDirective(p, to, flags)); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1413 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1414 |
msym.opens = opens.toList(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1415 |
directives.addAll(msym.opens); |
36526 | 1416 |
|
1417 |
msym.directives = directives.toList(); |
|
1418 |
||
1419 |
ListBuffer<InterimUsesDirective> uses = new ListBuffer<>(); |
|
1420 |
int nuses = nextChar(); |
|
1421 |
for (int i = 0; i < nuses; i++) { |
|
1422 |
Name srvc = readClassName(nextChar()); |
|
1423 |
uses.add(new InterimUsesDirective(srvc)); |
|
1424 |
} |
|
1425 |
interimUses = uses.toList(); |
|
1426 |
||
1427 |
ListBuffer<InterimProvidesDirective> provides = new ListBuffer<>(); |
|
1428 |
int nprovides = nextChar(); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1429 |
for (int p = 0; p < nprovides; p++) { |
36526 | 1430 |
Name srvc = readClassName(nextChar()); |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1431 |
int nimpls = nextChar(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1432 |
ListBuffer<Name> impls = new ListBuffer<>(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1433 |
for (int i = 0; i < nimpls; i++) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1434 |
impls.append(readClassName(nextChar())); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1435 |
provides.add(new InterimProvidesDirective(srvc, impls.toList())); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1436 |
} |
36526 | 1437 |
} |
1438 |
interimProvides = provides.toList(); |
|
1439 |
} |
|
1440 |
} |
|
1441 |
}, |
|
1442 |
||
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
1443 |
new AttributeReader(names.ModuleResolution, V53, CLASS_ATTRIBUTE) { |
36526 | 1444 |
@Override |
1445 |
protected boolean accepts(AttributeKind kind) { |
|
1446 |
return super.accepts(kind) && allowModules; |
|
1447 |
} |
|
1448 |
protected void read(Symbol sym, int attrLen) { |
|
1449 |
if (sym.kind == TYP && sym.owner.kind == MDL) { |
|
1450 |
ModuleSymbol msym = (ModuleSymbol) sym.owner; |
|
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
1451 |
msym.resolutionFlags.addAll(readModuleResolutionFlags(nextChar())); |
36526 | 1452 |
} |
1453 |
} |
|
1454 |
}, |
|
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1455 |
}; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1456 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1457 |
for (AttributeReader r: readers) |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1458 |
attributeReaders.put(r.name, r); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1459 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1460 |
|
13635
5c742eabba7c
7192068: (javac) provide a way for IDEs to produce Enclosing Method attributes.
ksrini
parents:
12335
diff
changeset
|
1461 |
protected void readEnclosingMethodAttr(Symbol sym) { |
10 | 1462 |
// sym is a nested class with an "Enclosing Method" attribute |
1463 |
// remove sym from it's current owners scope and place it in |
|
1464 |
// the scope specified by the attribute |
|
1465 |
sym.owner.members().remove(sym); |
|
1466 |
ClassSymbol self = (ClassSymbol)sym; |
|
1467 |
ClassSymbol c = readClassSymbol(nextChar()); |
|
24068 | 1468 |
NameAndType nt = readNameAndType(nextChar()); |
10 | 1469 |
|
45910
c7092e4591b2
8182450: javac aborts when generating ct.sym intermittently
jlahoda
parents:
45504
diff
changeset
|
1470 |
if (c.members_field == null || c.kind != TYP) |
9077
6ee59e40b258
7031108: NPE in javac.jvm.ClassReader.findMethod in PackageElement.enclosedElements from AP in incr build
jjg
parents:
8630
diff
changeset
|
1471 |
throw badClassFile("bad.enclosing.class", self, c); |
6ee59e40b258
7031108: NPE in javac.jvm.ClassReader.findMethod in PackageElement.enclosedElements from AP in incr build
jjg
parents:
8630
diff
changeset
|
1472 |
|
10 | 1473 |
MethodSymbol m = findMethod(nt, c.members_field, self.flags()); |
1474 |
if (nt != null && m == null) |
|
37001
594b4565d8a4
8151191: javac error when running javadoc on some inner classes
vromero
parents:
36526
diff
changeset
|
1475 |
throw badEnclosingMethod(self); |
10 | 1476 |
|
1477 |
self.name = simpleBinaryName(self.flatname, c.flatname) ; |
|
1478 |
self.owner = m != null ? m : c; |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
939
diff
changeset
|
1479 |
if (self.name.isEmpty()) |
5012
405341b6e9c5
6449781: TypeElement.getQualifiedName for anonymous classes returns null instead of an empty name
darcy
parents:
4872
diff
changeset
|
1480 |
self.fullname = names.empty; |
10 | 1481 |
else |
1482 |
self.fullname = ClassSymbol.formFullName(self.name, self.owner); |
|
1483 |
||
1484 |
if (m != null) { |
|
1485 |
((ClassType)sym.type).setEnclosingType(m.type); |
|
1486 |
} else if ((self.flags_field & STATIC) == 0) { |
|
1487 |
((ClassType)sym.type).setEnclosingType(c.type); |
|
1488 |
} else { |
|
1489 |
((ClassType)sym.type).setEnclosingType(Type.noType); |
|
1490 |
} |
|
41935
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
1491 |
enterTypevars(self, self.type); |
10 | 1492 |
if (!missingTypeVariables.isEmpty()) { |
22163 | 1493 |
ListBuffer<Type> typeVars = new ListBuffer<>(); |
10 | 1494 |
for (Type typevar : missingTypeVariables) { |
1495 |
typeVars.append(findTypeVar(typevar.tsym.name)); |
|
1496 |
} |
|
1497 |
foundTypeVariables = typeVars.toList(); |
|
1498 |
} else { |
|
1499 |
foundTypeVariables = List.nil(); |
|
1500 |
} |
|
1501 |
} |
|
1502 |
||
1503 |
// See java.lang.Class |
|
1504 |
private Name simpleBinaryName(Name self, Name enclosing) { |
|
54512
a84c46287f28
8215407: javac should reject class files with bad EnclosingMethod attributes
jlahoda
parents:
54339
diff
changeset
|
1505 |
if (!self.startsWith(enclosing)) { |
a84c46287f28
8215407: javac should reject class files with bad EnclosingMethod attributes
jlahoda
parents:
54339
diff
changeset
|
1506 |
throw badClassFile("bad.enclosing.method", self); |
a84c46287f28
8215407: javac should reject class files with bad EnclosingMethod attributes
jlahoda
parents:
54339
diff
changeset
|
1507 |
} |
a84c46287f28
8215407: javac should reject class files with bad EnclosingMethod attributes
jlahoda
parents:
54339
diff
changeset
|
1508 |
|
10 | 1509 |
String simpleBinaryName = self.toString().substring(enclosing.toString().length()); |
1510 |
if (simpleBinaryName.length() < 1 || simpleBinaryName.charAt(0) != '$') |
|
1511 |
throw badClassFile("bad.enclosing.method", self); |
|
1512 |
int index = 1; |
|
1513 |
while (index < simpleBinaryName.length() && |
|
1514 |
isAsciiDigit(simpleBinaryName.charAt(index))) |
|
1515 |
index++; |
|
1516 |
return names.fromString(simpleBinaryName.substring(index)); |
|
1517 |
} |
|
1518 |
||
1519 |
private MethodSymbol findMethod(NameAndType nt, Scope scope, long flags) { |
|
1520 |
if (nt == null) |
|
1521 |
return null; |
|
1522 |
||
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
1523 |
MethodType type = nt.uniqueType.type.asMethodType(); |
10 | 1524 |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
1525 |
for (Symbol sym : scope.getSymbolsByName(nt.name)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
1526 |
if (sym.kind == MTH && isSameBinaryType(sym.type.asMethodType(), type)) |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
1527 |
return (MethodSymbol)sym; |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
1528 |
} |
10 | 1529 |
|
1530 |
if (nt.name != names.init) |
|
1531 |
// not a constructor |
|
1532 |
return null; |
|
1533 |
if ((flags & INTERFACE) != 0) |
|
1534 |
// no enclosing instance |
|
1535 |
return null; |
|
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
1536 |
if (nt.uniqueType.type.getParameterTypes().isEmpty()) |
10 | 1537 |
// no parameters |
1538 |
return null; |
|
1539 |
||
1540 |
// A constructor of an inner class. |
|
1541 |
// Remove the first argument (the enclosing instance) |
|
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
1542 |
nt.setType(new MethodType(nt.uniqueType.type.getParameterTypes().tail, |
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
1543 |
nt.uniqueType.type.getReturnType(), |
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
1544 |
nt.uniqueType.type.getThrownTypes(), |
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
1545 |
syms.methodClass)); |
10 | 1546 |
// Try searching again |
1547 |
return findMethod(nt, scope, flags); |
|
1548 |
} |
|
1549 |
||
1550 |
/** Similar to Types.isSameType but avoids completion */ |
|
1551 |
private boolean isSameBinaryType(MethodType mt1, MethodType mt2) { |
|
1552 |
List<Type> types1 = types.erasure(mt1.getParameterTypes()) |
|
1553 |
.prepend(types.erasure(mt1.getReturnType())); |
|
1554 |
List<Type> types2 = mt2.getParameterTypes().prepend(mt2.getReturnType()); |
|
1555 |
while (!types1.isEmpty() && !types2.isEmpty()) { |
|
1556 |
if (types1.head.tsym != types2.head.tsym) |
|
1557 |
return false; |
|
1558 |
types1 = types1.tail; |
|
1559 |
types2 = types2.tail; |
|
1560 |
} |
|
1561 |
return types1.isEmpty() && types2.isEmpty(); |
|
1562 |
} |
|
1563 |
||
1564 |
/** |
|
1565 |
* Character.isDigit answers <tt>true</tt> to some non-ascii |
|
1566 |
* digits. This one does not. <b>copied from java.lang.Class</b> |
|
1567 |
*/ |
|
1568 |
private static boolean isAsciiDigit(char c) { |
|
1569 |
return '0' <= c && c <= '9'; |
|
1570 |
} |
|
1571 |
||
1572 |
/** Read member attributes. |
|
1573 |
*/ |
|
1574 |
void readMemberAttrs(Symbol sym) { |
|
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1575 |
readAttrs(sym, AttributeKind.MEMBER); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1576 |
} |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1577 |
|
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1578 |
void readAttrs(Symbol sym, AttributeKind kind) { |
10 | 1579 |
char ac = nextChar(); |
1580 |
for (int i = 0; i < ac; i++) { |
|
1581 |
Name attrName = readName(nextChar()); |
|
1582 |
int attrLen = nextInt(); |
|
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1583 |
AttributeReader r = attributeReaders.get(attrName); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1584 |
if (r != null && r.accepts(kind)) |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1585 |
r.read(sym, attrLen); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1586 |
else { |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1587 |
bp = bp + attrLen; |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1588 |
} |
10 | 1589 |
} |
1590 |
} |
|
1591 |
||
1592 |
private boolean readingClassAttr = false; |
|
1593 |
private List<Type> missingTypeVariables = List.nil(); |
|
1594 |
private List<Type> foundTypeVariables = List.nil(); |
|
1595 |
||
1596 |
/** Read class attributes. |
|
1597 |
*/ |
|
1598 |
void readClassAttrs(ClassSymbol c) { |
|
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
1599 |
readAttrs(c, AttributeKind.CLASS); |
10 | 1600 |
} |
1601 |
||
1602 |
/** Read code block. |
|
1603 |
*/ |
|
1604 |
Code readCode(Symbol owner) { |
|
1605 |
nextChar(); // max_stack |
|
1606 |
nextChar(); // max_locals |
|
1607 |
final int code_length = nextInt(); |
|
1608 |
bp += code_length; |
|
1609 |
final char exception_table_length = nextChar(); |
|
1610 |
bp += exception_table_length * 8; |
|
1611 |
readMemberAttrs(owner); |
|
1612 |
return null; |
|
1613 |
} |
|
1614 |
||
1615 |
/************************************************************************ |
|
1616 |
* Reading Java-language annotations |
|
1617 |
***********************************************************************/ |
|
1618 |
||
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1619 |
/** |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1620 |
* Save annotations. |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1621 |
*/ |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1622 |
List<CompoundAnnotationProxy> readAnnotations() { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1623 |
int numAttributes = nextChar(); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1624 |
ListBuffer<CompoundAnnotationProxy> annotations = new ListBuffer<>(); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1625 |
for (int i = 0; i < numAttributes; i++) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1626 |
annotations.append(readCompoundAnnotation()); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1627 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1628 |
return annotations.toList(); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1629 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1630 |
|
10 | 1631 |
/** Attach annotations. |
1632 |
*/ |
|
1633 |
void attachAnnotations(final Symbol sym) { |
|
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1634 |
attachAnnotations(sym, readAnnotations()); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1635 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1636 |
|
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1637 |
/** |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1638 |
* Attach annotations. |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1639 |
*/ |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1640 |
void attachAnnotations(final Symbol sym, List<CompoundAnnotationProxy> annotations) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1641 |
if (annotations.isEmpty()) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1642 |
return; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1643 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1644 |
ListBuffer<CompoundAnnotationProxy> proxies = new ListBuffer<>(); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1645 |
for (CompoundAnnotationProxy proxy : annotations) { |
51833
91fd24cf57d5
8209058: Cannot find annotation method 'value()' in type 'Profile+Annotation'
jlahoda
parents:
51719
diff
changeset
|
1646 |
if (proxy.type.tsym.flatName() == syms.proprietaryType.tsym.flatName()) |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1647 |
sym.flags_field |= PROPRIETARY; |
51833
91fd24cf57d5
8209058: Cannot find annotation method 'value()' in type 'Profile+Annotation'
jlahoda
parents:
51719
diff
changeset
|
1648 |
else if (proxy.type.tsym.flatName() == syms.profileType.tsym.flatName()) { |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1649 |
if (profile != Profile.DEFAULT) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1650 |
for (Pair<Name, Attribute> v : proxy.values) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1651 |
if (v.fst == names.value && v.snd instanceof Attribute.Constant) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1652 |
Attribute.Constant c = (Attribute.Constant)v.snd; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1653 |
if (c.type == syms.intType && ((Integer)c.value) > profile.value) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1654 |
sym.flags_field |= NOT_IN_PROFILE; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29842
diff
changeset
|
1655 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29842
diff
changeset
|
1656 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29842
diff
changeset
|
1657 |
} |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1658 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1659 |
} else { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1660 |
if (proxy.type.tsym == syms.annotationTargetType.tsym) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1661 |
target = proxy; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1662 |
} else if (proxy.type.tsym == syms.repeatableType.tsym) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1663 |
repeatable = proxy; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1664 |
} else if (proxy.type.tsym == syms.deprecatedType.tsym) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1665 |
sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1666 |
for (Pair<Name, Attribute> v : proxy.values) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1667 |
if (v.fst == names.forRemoval && v.snd instanceof Attribute.Constant) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1668 |
Attribute.Constant c = (Attribute.Constant)v.snd; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1669 |
if (c.type == syms.booleanType && ((Integer)c.value) != 0) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1670 |
sym.flags_field |= DEPRECATED_REMOVAL; |
41637 | 1671 |
} |
1672 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
29842
diff
changeset
|
1673 |
} |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
1674 |
} |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1675 |
proxies.append(proxy); |
10 | 1676 |
} |
1677 |
} |
|
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1678 |
annotate.normal(new AnnotationCompleter(sym, proxies.toList())); |
10 | 1679 |
} |
1680 |
||
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1681 |
/** Read parameter annotations. |
10 | 1682 |
*/ |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1683 |
void readParameterAnnotations(Symbol meth) { |
10 | 1684 |
int numParameters = buf[bp++] & 0xFF; |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1685 |
if (parameterAnnotations == null) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1686 |
parameterAnnotations = new ParameterAnnotations[numParameters]; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1687 |
} else if (parameterAnnotations.length != numParameters) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1688 |
throw badClassFile("bad.runtime.invisible.param.annotations", meth); |
10 | 1689 |
} |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1690 |
for (int pnum = 0; pnum < numParameters; pnum++) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1691 |
if (parameterAnnotations[pnum] == null) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1692 |
parameterAnnotations[pnum] = new ParameterAnnotations(); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1693 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
1694 |
parameterAnnotations[pnum].add(readAnnotations()); |
10 | 1695 |
} |
1696 |
} |
|
1697 |
||
15385 | 1698 |
void attachTypeAnnotations(final Symbol sym) { |
1699 |
int numAttributes = nextChar(); |
|
1700 |
if (numAttributes != 0) { |
|
20249
93f8eae31092
6386236: Please rename com.sun.tools.javac.util.ListBuffer.lb()
alundblad
parents:
20242
diff
changeset
|
1701 |
ListBuffer<TypeAnnotationProxy> proxies = new ListBuffer<>(); |
15385 | 1702 |
for (int i = 0; i < numAttributes; i++) |
1703 |
proxies.append(readTypeAnnotation()); |
|
1704 |
annotate.normal(new TypeAnnotationCompleter(sym, proxies.toList())); |
|
1705 |
} |
|
1706 |
} |
|
1707 |
||
10 | 1708 |
/** Attach the default value for an annotation element. |
1709 |
*/ |
|
1710 |
void attachAnnotationDefault(final Symbol sym) { |
|
1711 |
final MethodSymbol meth = (MethodSymbol)sym; // only on methods |
|
1712 |
final Attribute value = readAttributeValue(); |
|
14804
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1713 |
|
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1714 |
// The default value is set later during annotation. It might |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1715 |
// be the case that the Symbol sym is annotated _after_ the |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1716 |
// repeating instances that depend on this default value, |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1717 |
// because of this we set an interim value that tells us this |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1718 |
// element (most likely) has a default. |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1719 |
// |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1720 |
// Set interim value for now, reset just before we do this |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1721 |
// properly at annotate time. |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
1722 |
meth.defaultValue = value; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
13635
diff
changeset
|
1723 |
annotate.normal(new AnnotationDefaultCompleter(meth, value)); |
10 | 1724 |
} |
1725 |
||
1726 |
Type readTypeOrClassSymbol(int i) { |
|
1727 |
// support preliminary jsr175-format class files |
|
1728 |
if (buf[poolIdx[i]] == CONSTANT_Class) |
|
1729 |
return readClassSymbol(i).type; |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1730 |
return readTypeToProxy(i); |
10 | 1731 |
} |
1732 |
Type readEnumType(int i) { |
|
1733 |
// support preliminary jsr175-format class files |
|
1734 |
int index = poolIdx[i]; |
|
1735 |
int length = getChar(index + 1); |
|
1736 |
if (buf[index + length + 2] != ';') |
|
36526 | 1737 |
return enterClass(readName(i)).type; |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1738 |
return readTypeToProxy(i); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1739 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1740 |
Type readTypeToProxy(int i) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1741 |
if (currentModule.module_info == currentOwner) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1742 |
int index = poolIdx[i]; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1743 |
return new ProxyType(Arrays.copyOfRange(buf, index + 3, index + 3 + getChar(index + 1))); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1744 |
} else { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1745 |
return readType(i); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1746 |
} |
10 | 1747 |
} |
1748 |
||
1749 |
CompoundAnnotationProxy readCompoundAnnotation() { |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1750 |
Type t; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1751 |
if (currentModule.module_info == currentOwner) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1752 |
int index = poolIdx[nextChar()]; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1753 |
t = new ProxyType(Arrays.copyOfRange(buf, index + 3, index + 3 + getChar(index + 1))); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1754 |
} else { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1755 |
t = readTypeOrClassSymbol(nextChar()); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1756 |
} |
10 | 1757 |
int numFields = nextChar(); |
22163 | 1758 |
ListBuffer<Pair<Name,Attribute>> pairs = new ListBuffer<>(); |
10 | 1759 |
for (int i=0; i<numFields; i++) { |
1760 |
Name name = readName(nextChar()); |
|
1761 |
Attribute value = readAttributeValue(); |
|
22163 | 1762 |
pairs.append(new Pair<>(name, value)); |
10 | 1763 |
} |
1764 |
return new CompoundAnnotationProxy(t, pairs.toList()); |
|
1765 |
} |
|
1766 |
||
15385 | 1767 |
TypeAnnotationProxy readTypeAnnotation() { |
1768 |
TypeAnnotationPosition position = readPosition(); |
|
1769 |
CompoundAnnotationProxy proxy = readCompoundAnnotation(); |
|
1770 |
||
1771 |
return new TypeAnnotationProxy(proxy, position); |
|
1772 |
} |
|
1773 |
||
1774 |
TypeAnnotationPosition readPosition() { |
|
1775 |
int tag = nextByte(); // TargetType tag is a byte |
|
1776 |
||
1777 |
if (!TargetType.isValidTargetTypeValue(tag)) |
|
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
1778 |
throw badClassFile("bad.type.annotation.value", String.format("0x%02X", tag)); |
15385 | 1779 |
|
1780 |
TargetType type = TargetType.fromTargetTypeValue(tag); |
|
1781 |
||
1782 |
switch (type) { |
|
1783 |
// instanceof |
|
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1784 |
case INSTANCEOF: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1785 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1786 |
final TypeAnnotationPosition position = |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1787 |
TypeAnnotationPosition.instanceOf(readTypePath()); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1788 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1789 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1790 |
} |
15385 | 1791 |
// new expression |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1792 |
case NEW: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1793 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1794 |
final TypeAnnotationPosition position = |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1795 |
TypeAnnotationPosition.newObj(readTypePath()); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1796 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1797 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1798 |
} |
15718 | 1799 |
// constructor/method reference receiver |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1800 |
case CONSTRUCTOR_REFERENCE: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1801 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1802 |
final TypeAnnotationPosition position = |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1803 |
TypeAnnotationPosition.constructorRef(readTypePath()); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1804 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1805 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1806 |
} |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1807 |
case METHOD_REFERENCE: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1808 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1809 |
final TypeAnnotationPosition position = |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1810 |
TypeAnnotationPosition.methodRef(readTypePath()); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1811 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1812 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1813 |
} |
15385 | 1814 |
// local variable |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1815 |
case LOCAL_VARIABLE: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1816 |
final int table_length = nextChar(); |
24403
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1817 |
final int[] newLvarOffset = new int[table_length]; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1818 |
final int[] newLvarLength = new int[table_length]; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1819 |
final int[] newLvarIndex = new int[table_length]; |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1820 |
|
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1821 |
for (int i = 0; i < table_length; ++i) { |
24403
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1822 |
newLvarOffset[i] = nextChar(); |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1823 |
newLvarLength[i] = nextChar(); |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1824 |
newLvarIndex[i] = nextChar(); |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1825 |
} |
24403
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1826 |
|
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1827 |
final TypeAnnotationPosition position = |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1828 |
TypeAnnotationPosition.localVariable(readTypePath()); |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1829 |
position.lvarOffset = newLvarOffset; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1830 |
position.lvarLength = newLvarLength; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1831 |
position.lvarIndex = newLvarIndex; |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1832 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1833 |
} |
15385 | 1834 |
// resource variable |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1835 |
case RESOURCE_VARIABLE: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1836 |
final int table_length = nextChar(); |
24403
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1837 |
final int[] newLvarOffset = new int[table_length]; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1838 |
final int[] newLvarLength = new int[table_length]; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1839 |
final int[] newLvarIndex = new int[table_length]; |
15385 | 1840 |
|
1841 |
for (int i = 0; i < table_length; ++i) { |
|
24403
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1842 |
newLvarOffset[i] = nextChar(); |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1843 |
newLvarLength[i] = nextChar(); |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1844 |
newLvarIndex[i] = nextChar(); |
15385 | 1845 |
} |
24403
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1846 |
|
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1847 |
final TypeAnnotationPosition position = |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1848 |
TypeAnnotationPosition.resourceVariable(readTypePath()); |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1849 |
position.lvarOffset = newLvarOffset; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1850 |
position.lvarLength = newLvarLength; |
f2ce14657001
8035763: Error parsing binary type annotations data in javac
emc
parents:
24396
diff
changeset
|
1851 |
position.lvarIndex = newLvarIndex; |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1852 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1853 |
} |
15385 | 1854 |
// exception parameter |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1855 |
case EXCEPTION_PARAMETER: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1856 |
final int exception_index = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1857 |
final TypeAnnotationPosition position = |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1858 |
TypeAnnotationPosition.exceptionParameter(readTypePath()); |
23975
c7c81595aea9
8040319: Clean up type annotation exception index generating code in Code.java
emc
parents:
23790
diff
changeset
|
1859 |
position.setExceptionIndex(exception_index); |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1860 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1861 |
} |
15385 | 1862 |
// method receiver |
1863 |
case METHOD_RECEIVER: |
|
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1864 |
return TypeAnnotationPosition.methodReceiver(readTypePath()); |
15385 | 1865 |
// type parameter |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1866 |
case CLASS_TYPE_PARAMETER: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1867 |
final int parameter_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1868 |
return TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1869 |
.typeParameter(readTypePath(), parameter_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1870 |
} |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1871 |
case METHOD_TYPE_PARAMETER: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1872 |
final int parameter_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1873 |
return TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1874 |
.methodTypeParameter(readTypePath(), parameter_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1875 |
} |
15385 | 1876 |
// type parameter bound |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1877 |
case CLASS_TYPE_PARAMETER_BOUND: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1878 |
final int parameter_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1879 |
final int bound_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1880 |
return TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1881 |
.typeParameterBound(readTypePath(), parameter_index, |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1882 |
bound_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1883 |
} |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1884 |
case METHOD_TYPE_PARAMETER_BOUND: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1885 |
final int parameter_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1886 |
final int bound_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1887 |
return TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1888 |
.methodTypeParameterBound(readTypePath(), parameter_index, |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1889 |
bound_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1890 |
} |
15385 | 1891 |
// class extends or implements clause |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1892 |
case CLASS_EXTENDS: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1893 |
final int type_index = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1894 |
return TypeAnnotationPosition.classExtends(readTypePath(), |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1895 |
type_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1896 |
} |
15385 | 1897 |
// throws |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1898 |
case THROWS: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1899 |
final int type_index = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1900 |
return TypeAnnotationPosition.methodThrows(readTypePath(), |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1901 |
type_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1902 |
} |
15385 | 1903 |
// method parameter |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1904 |
case METHOD_FORMAL_PARAMETER: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1905 |
final int parameter_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1906 |
return TypeAnnotationPosition.methodParameter(readTypePath(), |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1907 |
parameter_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1908 |
} |
15718 | 1909 |
// type cast |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1910 |
case CAST: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1911 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1912 |
final int type_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1913 |
final TypeAnnotationPosition position = |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1914 |
TypeAnnotationPosition.typeCast(readTypePath(), type_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1915 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1916 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1917 |
} |
15385 | 1918 |
// method/constructor/reference type argument |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1919 |
case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1920 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1921 |
final int type_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1922 |
final TypeAnnotationPosition position = TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1923 |
.constructorInvocationTypeArg(readTypePath(), type_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1924 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1925 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1926 |
} |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1927 |
case METHOD_INVOCATION_TYPE_ARGUMENT: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1928 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1929 |
final int type_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1930 |
final TypeAnnotationPosition position = TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1931 |
.methodInvocationTypeArg(readTypePath(), type_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1932 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1933 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1934 |
} |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1935 |
case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1936 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1937 |
final int type_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1938 |
final TypeAnnotationPosition position = TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1939 |
.constructorRefTypeArg(readTypePath(), type_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1940 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1941 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1942 |
} |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1943 |
case METHOD_REFERENCE_TYPE_ARGUMENT: { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1944 |
final int offset = nextChar(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1945 |
final int type_index = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1946 |
final TypeAnnotationPosition position = TypeAnnotationPosition |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1947 |
.methodRefTypeArg(readTypePath(), type_index); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1948 |
position.offset = offset; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1949 |
return position; |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1950 |
} |
15385 | 1951 |
// We don't need to worry about these |
1952 |
case METHOD_RETURN: |
|
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1953 |
return TypeAnnotationPosition.methodReturn(readTypePath()); |
15385 | 1954 |
case FIELD: |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1955 |
return TypeAnnotationPosition.field(readTypePath()); |
26532
aa84b6606229
8056021: checkin for JDK-8027262 breaks Checker Framework
jfranck
parents:
26266
diff
changeset
|
1956 |
case UNKNOWN: |
aa84b6606229
8056021: checkin for JDK-8027262 breaks Checker Framework
jfranck
parents:
26266
diff
changeset
|
1957 |
throw new AssertionError("jvm.ClassReader: UNKNOWN target type should never occur!"); |
15385 | 1958 |
default: |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1959 |
throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + type); |
15385 | 1960 |
} |
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1961 |
} |
15385 | 1962 |
|
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1963 |
List<TypeAnnotationPosition.TypePathEntry> readTypePath() { |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1964 |
int len = nextByte(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1965 |
ListBuffer<Integer> loc = new ListBuffer<>(); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1966 |
for (int i = 0; i < len * TypeAnnotationPosition.TypePathEntry.bytesPerEntry; ++i) |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1967 |
loc = loc.append(nextByte()); |
15385 | 1968 |
|
22702
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1969 |
return TypeAnnotationPosition.getTypePathFromBinary(loc.toList()); |
1297fbaf34fa
8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions
emc
parents:
22442
diff
changeset
|
1970 |
|
15385 | 1971 |
} |
1972 |
||
10 | 1973 |
Attribute readAttributeValue() { |
1974 |
char c = (char) buf[bp++]; |
|
1975 |
switch (c) { |
|
1976 |
case 'B': |
|
1977 |
return new Attribute.Constant(syms.byteType, readPool(nextChar())); |
|
1978 |
case 'C': |
|
1979 |
return new Attribute.Constant(syms.charType, readPool(nextChar())); |
|
1980 |
case 'D': |
|
1981 |
return new Attribute.Constant(syms.doubleType, readPool(nextChar())); |
|
1982 |
case 'F': |
|
1983 |
return new Attribute.Constant(syms.floatType, readPool(nextChar())); |
|
1984 |
case 'I': |
|
1985 |
return new Attribute.Constant(syms.intType, readPool(nextChar())); |
|
1986 |
case 'J': |
|
1987 |
return new Attribute.Constant(syms.longType, readPool(nextChar())); |
|
1988 |
case 'S': |
|
1989 |
return new Attribute.Constant(syms.shortType, readPool(nextChar())); |
|
1990 |
case 'Z': |
|
1991 |
return new Attribute.Constant(syms.booleanType, readPool(nextChar())); |
|
1992 |
case 's': |
|
1993 |
return new Attribute.Constant(syms.stringType, readPool(nextChar()).toString()); |
|
1994 |
case 'e': |
|
1995 |
return new EnumAttributeProxy(readEnumType(nextChar()), readName(nextChar())); |
|
1996 |
case 'c': |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
1997 |
return new ClassAttributeProxy(readTypeOrClassSymbol(nextChar())); |
10 | 1998 |
case '[': { |
1999 |
int n = nextChar(); |
|
22163 | 2000 |
ListBuffer<Attribute> l = new ListBuffer<>(); |
10 | 2001 |
for (int i=0; i<n; i++) |
2002 |
l.append(readAttributeValue()); |
|
2003 |
return new ArrayAttributeProxy(l.toList()); |
|
2004 |
} |
|
2005 |
case '@': |
|
2006 |
return readCompoundAnnotation(); |
|
2007 |
default: |
|
2008 |
throw new AssertionError("unknown annotation tag '" + c + "'"); |
|
2009 |
} |
|
2010 |
} |
|
2011 |
||
2012 |
interface ProxyVisitor extends Attribute.Visitor { |
|
2013 |
void visitEnumAttributeProxy(EnumAttributeProxy proxy); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2014 |
void visitClassAttributeProxy(ClassAttributeProxy proxy); |
10 | 2015 |
void visitArrayAttributeProxy(ArrayAttributeProxy proxy); |
2016 |
void visitCompoundAnnotationProxy(CompoundAnnotationProxy proxy); |
|
2017 |
} |
|
2018 |
||
2019 |
static class EnumAttributeProxy extends Attribute { |
|
2020 |
Type enumType; |
|
2021 |
Name enumerator; |
|
2022 |
public EnumAttributeProxy(Type enumType, Name enumerator) { |
|
2023 |
super(null); |
|
2024 |
this.enumType = enumType; |
|
2025 |
this.enumerator = enumerator; |
|
2026 |
} |
|
2027 |
public void accept(Visitor v) { ((ProxyVisitor)v).visitEnumAttributeProxy(this); } |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2028 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
10 | 2029 |
public String toString() { |
2030 |
return "/*proxy enum*/" + enumType + "." + enumerator; |
|
2031 |
} |
|
2032 |
} |
|
2033 |
||
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2034 |
static class ClassAttributeProxy extends Attribute { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2035 |
Type classType; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2036 |
public ClassAttributeProxy(Type classType) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2037 |
super(null); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2038 |
this.classType = classType; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2039 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2040 |
public void accept(Visitor v) { ((ProxyVisitor)v).visitClassAttributeProxy(this); } |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2041 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2042 |
public String toString() { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2043 |
return "/*proxy class*/" + classType + ".class"; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2044 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2045 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2046 |
|
10 | 2047 |
static class ArrayAttributeProxy extends Attribute { |
2048 |
List<Attribute> values; |
|
2049 |
ArrayAttributeProxy(List<Attribute> values) { |
|
2050 |
super(null); |
|
2051 |
this.values = values; |
|
2052 |
} |
|
2053 |
public void accept(Visitor v) { ((ProxyVisitor)v).visitArrayAttributeProxy(this); } |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2054 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
10 | 2055 |
public String toString() { |
2056 |
return "{" + values + "}"; |
|
2057 |
} |
|
2058 |
} |
|
2059 |
||
2060 |
/** A temporary proxy representing a compound attribute. |
|
2061 |
*/ |
|
2062 |
static class CompoundAnnotationProxy extends Attribute { |
|
2063 |
final List<Pair<Name,Attribute>> values; |
|
2064 |
public CompoundAnnotationProxy(Type type, |
|
2065 |
List<Pair<Name,Attribute>> values) { |
|
2066 |
super(type); |
|
2067 |
this.values = values; |
|
2068 |
} |
|
2069 |
public void accept(Visitor v) { ((ProxyVisitor)v).visitCompoundAnnotationProxy(this); } |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2070 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
10 | 2071 |
public String toString() { |
7624
c31b0ea95b37
6999210: javac should be able to warn of anomalous conditions in classfiles
jjg
parents:
7330
diff
changeset
|
2072 |
StringBuilder buf = new StringBuilder(); |
10 | 2073 |
buf.append("@"); |
2074 |
buf.append(type.tsym.getQualifiedName()); |
|
2075 |
buf.append("/*proxy*/{"); |
|
2076 |
boolean first = true; |
|
2077 |
for (List<Pair<Name,Attribute>> v = values; |
|
2078 |
v.nonEmpty(); v = v.tail) { |
|
2079 |
Pair<Name,Attribute> value = v.head; |
|
2080 |
if (!first) buf.append(","); |
|
2081 |
first = false; |
|
2082 |
buf.append(value.fst); |
|
2083 |
buf.append("="); |
|
2084 |
buf.append(value.snd); |
|
2085 |
} |
|
2086 |
buf.append("}"); |
|
2087 |
return buf.toString(); |
|
2088 |
} |
|
2089 |
} |
|
2090 |
||
3149 | 2091 |
/** A temporary proxy representing a type annotation. |
2092 |
*/ |
|
2093 |
static class TypeAnnotationProxy { |
|
2094 |
final CompoundAnnotationProxy compound; |
|
2095 |
final TypeAnnotationPosition position; |
|
2096 |
public TypeAnnotationProxy(CompoundAnnotationProxy compound, |
|
2097 |
TypeAnnotationPosition position) { |
|
2098 |
this.compound = compound; |
|
2099 |
this.position = position; |
|
2100 |
} |
|
2101 |
} |
|
2102 |
||
10 | 2103 |
class AnnotationDeproxy implements ProxyVisitor { |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2104 |
private ClassSymbol requestingOwner; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2105 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2106 |
AnnotationDeproxy(ClassSymbol owner) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2107 |
this.requestingOwner = owner; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2108 |
} |
10 | 2109 |
|
2110 |
List<Attribute.Compound> deproxyCompoundList(List<CompoundAnnotationProxy> pl) { |
|
2111 |
// also must fill in types!!!! |
|
22163 | 2112 |
ListBuffer<Attribute.Compound> buf = new ListBuffer<>(); |
10 | 2113 |
for (List<CompoundAnnotationProxy> l = pl; l.nonEmpty(); l=l.tail) { |
2114 |
buf.append(deproxyCompound(l.head)); |
|
2115 |
} |
|
2116 |
return buf.toList(); |
|
2117 |
} |
|
2118 |
||
2119 |
Attribute.Compound deproxyCompound(CompoundAnnotationProxy a) { |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2120 |
Type annotationType = resolvePossibleProxyType(a.type); |
22163 | 2121 |
ListBuffer<Pair<Symbol.MethodSymbol,Attribute>> buf = new ListBuffer<>(); |
10 | 2122 |
for (List<Pair<Name,Attribute>> l = a.values; |
2123 |
l.nonEmpty(); |
|
2124 |
l = l.tail) { |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2125 |
MethodSymbol meth = findAccessMethod(annotationType, l.head.fst); |
22163 | 2126 |
buf.append(new Pair<>(meth, deproxy(meth.type.getReturnType(), l.head.snd))); |
10 | 2127 |
} |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2128 |
return new Attribute.Compound(annotationType, buf.toList()); |
10 | 2129 |
} |
2130 |
||
2131 |
MethodSymbol findAccessMethod(Type container, Name name) { |
|
2132 |
CompletionFailure failure = null; |
|
2133 |
try { |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
2134 |
for (Symbol sym : container.tsym.members().getSymbolsByName(name)) { |
10 | 2135 |
if (sym.kind == MTH && sym.type.getParameterTypes().length() == 0) |
2136 |
return (MethodSymbol) sym; |
|
2137 |
} |
|
2138 |
} catch (CompletionFailure ex) { |
|
2139 |
failure = ex; |
|
2140 |
} |
|
2141 |
// The method wasn't found: emit a warning and recover |
|
2142 |
JavaFileObject prevSource = log.useSource(requestingOwner.classfile); |
|
2143 |
try { |
|
28333
8eeea699174c
8068639: Make certain annotation classfile warnings opt-in
darcy
parents:
27858
diff
changeset
|
2144 |
if (lintClassfile) { |
8eeea699174c
8068639: Make certain annotation classfile warnings opt-in
darcy
parents:
27858
diff
changeset
|
2145 |
if (failure == null) { |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2146 |
log.warning(Warnings.AnnotationMethodNotFound(container, name)); |
28333
8eeea699174c
8068639: Make certain annotation classfile warnings opt-in
darcy
parents:
27858
diff
changeset
|
2147 |
} else { |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2148 |
log.warning(Warnings.AnnotationMethodNotFoundReason(container, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2149 |
name, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2150 |
failure.getDetailValue()));//diagnostic, if present |
28333
8eeea699174c
8068639: Make certain annotation classfile warnings opt-in
darcy
parents:
27858
diff
changeset
|
2151 |
} |
10 | 2152 |
} |
2153 |
} finally { |
|
2154 |
log.useSource(prevSource); |
|
2155 |
} |
|
2156 |
// Construct a new method type and symbol. Use bottom |
|
2157 |
// type (typeof null) as return type because this type is |
|
2158 |
// a subtype of all reference types and can be converted |
|
2159 |
// to primitive types by unboxing. |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42822
diff
changeset
|
2160 |
MethodType mt = new MethodType(List.nil(), |
10 | 2161 |
syms.botType, |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42822
diff
changeset
|
2162 |
List.nil(), |
10 | 2163 |
syms.methodClass); |
2164 |
return new MethodSymbol(PUBLIC | ABSTRACT, name, mt, container.tsym); |
|
2165 |
} |
|
2166 |
||
2167 |
Attribute result; |
|
2168 |
Type type; |
|
2169 |
Attribute deproxy(Type t, Attribute a) { |
|
2170 |
Type oldType = type; |
|
2171 |
try { |
|
2172 |
type = t; |
|
2173 |
a.accept(this); |
|
2174 |
return result; |
|
2175 |
} finally { |
|
2176 |
type = oldType; |
|
2177 |
} |
|
2178 |
} |
|
2179 |
||
2180 |
// implement Attribute.Visitor below |
|
2181 |
||
2182 |
public void visitConstant(Attribute.Constant value) { |
|
2183 |
// assert value.type == type; |
|
2184 |
result = value; |
|
2185 |
} |
|
2186 |
||
2187 |
public void visitClass(Attribute.Class clazz) { |
|
2188 |
result = clazz; |
|
2189 |
} |
|
2190 |
||
2191 |
public void visitEnum(Attribute.Enum e) { |
|
2192 |
throw new AssertionError(); // shouldn't happen |
|
2193 |
} |
|
2194 |
||
2195 |
public void visitCompound(Attribute.Compound compound) { |
|
2196 |
throw new AssertionError(); // shouldn't happen |
|
2197 |
} |
|
2198 |
||
2199 |
public void visitArray(Attribute.Array array) { |
|
2200 |
throw new AssertionError(); // shouldn't happen |
|
2201 |
} |
|
2202 |
||
2203 |
public void visitError(Attribute.Error e) { |
|
2204 |
throw new AssertionError(); // shouldn't happen |
|
2205 |
} |
|
2206 |
||
2207 |
public void visitEnumAttributeProxy(EnumAttributeProxy proxy) { |
|
2208 |
// type.tsym.flatName() should == proxy.enumFlatName |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2209 |
Type enumType = resolvePossibleProxyType(proxy.enumType); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2210 |
TypeSymbol enumTypeSym = enumType.tsym; |
10 | 2211 |
VarSymbol enumerator = null; |
9603
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2212 |
CompletionFailure failure = null; |
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2213 |
try { |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
2214 |
for (Symbol sym : enumTypeSym.members().getSymbolsByName(proxy.enumerator)) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
2215 |
if (sym.kind == VAR) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
2216 |
enumerator = (VarSymbol)sym; |
9603
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2217 |
break; |
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2218 |
} |
10 | 2219 |
} |
2220 |
} |
|
9603
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2221 |
catch (CompletionFailure ex) { |
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2222 |
failure = ex; |
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2223 |
} |
10 | 2224 |
if (enumerator == null) { |
9603
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2225 |
if (failure != null) { |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2226 |
log.warning(Warnings.UnknownEnumConstantReason(currentClassFile, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2227 |
enumTypeSym, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2228 |
proxy.enumerator, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2229 |
failure.getDiagnostic())); |
9603
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2230 |
} else { |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2231 |
log.warning(Warnings.UnknownEnumConstant(currentClassFile, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2232 |
enumTypeSym, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2233 |
proxy.enumerator)); |
9603
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2234 |
} |
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2235 |
result = new Attribute.Enum(enumTypeSym.type, |
fa337b87574b
6550655: com.sun.tools.javac.code.Symbol$CompletionFailure
mcimadamore
parents:
9082
diff
changeset
|
2236 |
new VarSymbol(0, proxy.enumerator, syms.botType, enumTypeSym)); |
10 | 2237 |
} else { |
2238 |
result = new Attribute.Enum(enumTypeSym.type, enumerator); |
|
2239 |
} |
|
2240 |
} |
|
2241 |
||
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2242 |
@Override |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2243 |
public void visitClassAttributeProxy(ClassAttributeProxy proxy) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2244 |
Type classType = resolvePossibleProxyType(proxy.classType); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2245 |
result = new Attribute.Class(types, classType); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2246 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2247 |
|
10 | 2248 |
public void visitArrayAttributeProxy(ArrayAttributeProxy proxy) { |
2249 |
int length = proxy.values.length(); |
|
2250 |
Attribute[] ats = new Attribute[length]; |
|
2251 |
Type elemtype = types.elemtype(type); |
|
2252 |
int i = 0; |
|
2253 |
for (List<Attribute> p = proxy.values; p.nonEmpty(); p = p.tail) { |
|
2254 |
ats[i++] = deproxy(elemtype, p.head); |
|
2255 |
} |
|
2256 |
result = new Attribute.Array(type, ats); |
|
2257 |
} |
|
2258 |
||
2259 |
public void visitCompoundAnnotationProxy(CompoundAnnotationProxy proxy) { |
|
2260 |
result = deproxyCompound(proxy); |
|
2261 |
} |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2262 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2263 |
Type resolvePossibleProxyType(Type t) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2264 |
if (t instanceof ProxyType) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2265 |
Assert.check(requestingOwner.owner.kind == MDL); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2266 |
ModuleSymbol prevCurrentModule = currentModule; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2267 |
currentModule = (ModuleSymbol) requestingOwner.owner; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2268 |
try { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2269 |
return ((ProxyType) t).resolve(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2270 |
} finally { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2271 |
currentModule = prevCurrentModule; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2272 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2273 |
} else { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2274 |
return t; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2275 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2276 |
} |
10 | 2277 |
} |
2278 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2279 |
class AnnotationDefaultCompleter extends AnnotationDeproxy implements Runnable { |
10 | 2280 |
final MethodSymbol sym; |
2281 |
final Attribute value; |
|
2282 |
final JavaFileObject classFile = currentClassFile; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2283 |
|
10 | 2284 |
AnnotationDefaultCompleter(MethodSymbol sym, Attribute value) { |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2285 |
super(currentOwner.kind == MTH |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2286 |
? currentOwner.enclClass() : (ClassSymbol)currentOwner); |
10 | 2287 |
this.sym = sym; |
2288 |
this.value = value; |
|
2289 |
} |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2290 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2291 |
@Override |
21040
3e32f68d2151
8026510: The name of com.sun.tools.javac.comp.Annotate.Annotator is confusing
jlahoda
parents:
21006
diff
changeset
|
2292 |
public void run() { |
10 | 2293 |
JavaFileObject previousClassFile = currentClassFile; |
2294 |
try { |
|
14804
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
2295 |
// Reset the interim value set earlier in |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
2296 |
// attachAnnotationDefault(). |
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14725
diff
changeset
|
2297 |
sym.defaultValue = null; |
10 | 2298 |
currentClassFile = classFile; |
2299 |
sym.defaultValue = deproxy(sym.type.getReturnType(), value); |
|
2300 |
} finally { |
|
2301 |
currentClassFile = previousClassFile; |
|
2302 |
} |
|
2303 |
} |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2304 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2305 |
@Override |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2306 |
public String toString() { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2307 |
return " ClassReader store default for " + sym.owner + "." + sym + " is " + value; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2308 |
} |
10 | 2309 |
} |
2310 |
||
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2311 |
class AnnotationCompleter extends AnnotationDeproxy implements Runnable { |
10 | 2312 |
final Symbol sym; |
2313 |
final List<CompoundAnnotationProxy> l; |
|
2314 |
final JavaFileObject classFile; |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2315 |
|
10 | 2316 |
AnnotationCompleter(Symbol sym, List<CompoundAnnotationProxy> l) { |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2317 |
super(currentOwner.kind == MTH |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2318 |
? currentOwner.enclClass() : (ClassSymbol)currentOwner); |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2319 |
if (sym.kind == TYP && sym.owner.kind == MDL) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2320 |
this.sym = sym.owner; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2321 |
} else { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2322 |
this.sym = sym; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2323 |
} |
10 | 2324 |
this.l = l; |
2325 |
this.classFile = currentClassFile; |
|
2326 |
} |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2327 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2328 |
@Override |
21040
3e32f68d2151
8026510: The name of com.sun.tools.javac.comp.Annotate.Annotator is confusing
jlahoda
parents:
21006
diff
changeset
|
2329 |
public void run() { |
10 | 2330 |
JavaFileObject previousClassFile = currentClassFile; |
2331 |
try { |
|
2332 |
currentClassFile = classFile; |
|
2333 |
List<Attribute.Compound> newList = deproxyCompoundList(l); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2334 |
for (Attribute.Compound attr : newList) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2335 |
if (attr.type.tsym == syms.deprecatedType.tsym) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2336 |
sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2337 |
Attribute forRemoval = attr.member(names.forRemoval); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2338 |
if (forRemoval instanceof Attribute.Constant) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2339 |
Attribute.Constant c = (Attribute.Constant) forRemoval; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2340 |
if (c.type == syms.booleanType && ((Integer) c.value) != 0) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2341 |
sym.flags_field |= DEPRECATED_REMOVAL; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2342 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2343 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2344 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2345 |
} |
18010
604faee85350
8004643: Reduce javac space overhead introduced with compiler support for repeating annotations
jjg
parents:
17578
diff
changeset
|
2346 |
if (sym.annotationsPendingCompletion()) { |
604faee85350
8004643: Reduce javac space overhead introduced with compiler support for repeating annotations
jjg
parents:
17578
diff
changeset
|
2347 |
sym.setDeclarationAttributes(newList); |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
13635
diff
changeset
|
2348 |
} else { |
18010
604faee85350
8004643: Reduce javac space overhead introduced with compiler support for repeating annotations
jjg
parents:
17578
diff
changeset
|
2349 |
sym.appendAttributes(newList); |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
13635
diff
changeset
|
2350 |
} |
10 | 2351 |
} finally { |
2352 |
currentClassFile = previousClassFile; |
|
2353 |
} |
|
2354 |
} |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2355 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2356 |
@Override |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2357 |
public String toString() { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2358 |
return " ClassReader annotate " + sym.owner + "." + sym + " with " + l; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2359 |
} |
10 | 2360 |
} |
2361 |
||
15385 | 2362 |
class TypeAnnotationCompleter extends AnnotationCompleter { |
2363 |
||
2364 |
List<TypeAnnotationProxy> proxies; |
|
2365 |
||
2366 |
TypeAnnotationCompleter(Symbol sym, |
|
2367 |
List<TypeAnnotationProxy> proxies) { |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42822
diff
changeset
|
2368 |
super(sym, List.nil()); |
15385 | 2369 |
this.proxies = proxies; |
2370 |
} |
|
2371 |
||
2372 |
List<Attribute.TypeCompound> deproxyTypeCompoundList(List<TypeAnnotationProxy> proxies) { |
|
20249
93f8eae31092
6386236: Please rename com.sun.tools.javac.util.ListBuffer.lb()
alundblad
parents:
20242
diff
changeset
|
2373 |
ListBuffer<Attribute.TypeCompound> buf = new ListBuffer<>(); |
15385 | 2374 |
for (TypeAnnotationProxy proxy: proxies) { |
2375 |
Attribute.Compound compound = deproxyCompound(proxy.compound); |
|
2376 |
Attribute.TypeCompound typeCompound = new Attribute.TypeCompound(compound, proxy.position); |
|
2377 |
buf.add(typeCompound); |
|
2378 |
} |
|
2379 |
return buf.toList(); |
|
2380 |
} |
|
2381 |
||
2382 |
@Override |
|
21040
3e32f68d2151
8026510: The name of com.sun.tools.javac.comp.Annotate.Annotator is confusing
jlahoda
parents:
21006
diff
changeset
|
2383 |
public void run() { |
15385 | 2384 |
JavaFileObject previousClassFile = currentClassFile; |
2385 |
try { |
|
2386 |
currentClassFile = classFile; |
|
2387 |
List<Attribute.TypeCompound> newList = deproxyTypeCompoundList(proxies); |
|
18010
604faee85350
8004643: Reduce javac space overhead introduced with compiler support for repeating annotations
jjg
parents:
17578
diff
changeset
|
2388 |
sym.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes())); |
15385 | 2389 |
} finally { |
2390 |
currentClassFile = previousClassFile; |
|
2391 |
} |
|
2392 |
} |
|
2393 |
} |
|
2394 |
||
10 | 2395 |
|
2396 |
/************************************************************************ |
|
2397 |
* Reading Symbols |
|
2398 |
***********************************************************************/ |
|
2399 |
||
2400 |
/** Read a field. |
|
2401 |
*/ |
|
2402 |
VarSymbol readField() { |
|
2403 |
long flags = adjustFieldFlags(nextChar()); |
|
2404 |
Name name = readName(nextChar()); |
|
2405 |
Type type = readType(nextChar()); |
|
2406 |
VarSymbol v = new VarSymbol(flags, name, type, currentOwner); |
|
2407 |
readMemberAttrs(v); |
|
2408 |
return v; |
|
2409 |
} |
|
2410 |
||
2411 |
/** Read a method. |
|
2412 |
*/ |
|
2413 |
MethodSymbol readMethod() { |
|
2414 |
long flags = adjustMethodFlags(nextChar()); |
|
2415 |
Name name = readName(nextChar()); |
|
2416 |
Type type = readType(nextChar()); |
|
14547 | 2417 |
if (currentOwner.isInterface() && |
2418 |
(flags & ABSTRACT) == 0 && !name.equals(names.clinit)) { |
|
24606
12c0ca21f8dc
8042406: javac.jvm.ClassReader.readClassFile() is using Target to verify valid major versions
ntoda
parents:
24604
diff
changeset
|
2419 |
if (majorVersion > Version.V52.major || |
12c0ca21f8dc
8042406: javac.jvm.ClassReader.readClassFile() is using Target to verify valid major versions
ntoda
parents:
24604
diff
changeset
|
2420 |
(majorVersion == Version.V52.major && minorVersion >= Version.V52.minor)) { |
44183
17244500b154
8175184: Annotation processor observes interface private methods as default methods
sadayapalam
parents:
43268
diff
changeset
|
2421 |
if ((flags & (STATIC | PRIVATE)) == 0) { |
21006
534673718919
8025087: Annotation processing api returns default modifier for interface static method
jlahoda
parents:
20249
diff
changeset
|
2422 |
currentOwner.flags_field |= DEFAULT; |
534673718919
8025087: Annotation processing api returns default modifier for interface static method
jlahoda
parents:
20249
diff
changeset
|
2423 |
flags |= DEFAULT | ABSTRACT; |
534673718919
8025087: Annotation processing api returns default modifier for interface static method
jlahoda
parents:
20249
diff
changeset
|
2424 |
} |
14547 | 2425 |
} else { |
2426 |
//protect against ill-formed classfiles |
|
21006
534673718919
8025087: Annotation processing api returns default modifier for interface static method
jlahoda
parents:
20249
diff
changeset
|
2427 |
throw badClassFile((flags & STATIC) == 0 ? "invalid.default.interface" : "invalid.static.interface", |
534673718919
8025087: Annotation processing api returns default modifier for interface static method
jlahoda
parents:
20249
diff
changeset
|
2428 |
Integer.toString(majorVersion), |
534673718919
8025087: Annotation processing api returns default modifier for interface static method
jlahoda
parents:
20249
diff
changeset
|
2429 |
Integer.toString(minorVersion)); |
14547 | 2430 |
} |
2431 |
} |
|
10 | 2432 |
if (name == names.init && currentOwner.hasOuterInstance()) { |
2433 |
// Sometimes anonymous classes don't have an outer |
|
2434 |
// instance, however, there is no reliable way to tell so |
|
2435 |
// we never strip this$n |
|
41991
cc8a2784dd4c
8166700: NPE during invoking getEnclosedElements() on javax.lang.model.element.Element instance representing a package
jlahoda
parents:
41935
diff
changeset
|
2436 |
// ditto for local classes. Local classes that have an enclosing method set |
cc8a2784dd4c
8166700: NPE during invoking getEnclosedElements() on javax.lang.model.element.Element instance representing a package
jlahoda
parents:
41935
diff
changeset
|
2437 |
// won't pass the "hasOuterInstance" check above, but those that don't have an |
cc8a2784dd4c
8166700: NPE during invoking getEnclosedElements() on javax.lang.model.element.Element instance representing a package
jlahoda
parents:
41935
diff
changeset
|
2438 |
// enclosing method (i.e. from initializers) will pass that check. |
cc8a2784dd4c
8166700: NPE during invoking getEnclosedElements() on javax.lang.model.element.Element instance representing a package
jlahoda
parents:
41935
diff
changeset
|
2439 |
boolean local = !currentOwner.owner.members().includes(currentOwner, LookupKind.NON_RECURSIVE); |
cc8a2784dd4c
8166700: NPE during invoking getEnclosedElements() on javax.lang.model.element.Element instance representing a package
jlahoda
parents:
41935
diff
changeset
|
2440 |
if (!currentOwner.name.isEmpty() && !local) |
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2441 |
type = new MethodType(adjustMethodParams(flags, type.getParameterTypes()), |
10 | 2442 |
type.getReturnType(), |
2443 |
type.getThrownTypes(), |
|
2444 |
syms.methodClass); |
|
2445 |
} |
|
2446 |
MethodSymbol m = new MethodSymbol(flags, name, type, currentOwner); |
|
18389
a425d0819f36
8016569: javac, add new flag for polymorphic method signatures
vromero
parents:
18010
diff
changeset
|
2447 |
if (types.isSignaturePolymorphic(m)) { |
a425d0819f36
8016569: javac, add new flag for polymorphic method signatures
vromero
parents:
18010
diff
changeset
|
2448 |
m.flags_field |= SIGNATURE_POLYMORPHIC; |
a425d0819f36
8016569: javac, add new flag for polymorphic method signatures
vromero
parents:
18010
diff
changeset
|
2449 |
} |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2450 |
if (saveParameterNames) |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2451 |
initParameterNames(m); |
10 | 2452 |
Symbol prevOwner = currentOwner; |
2453 |
currentOwner = m; |
|
2454 |
try { |
|
2455 |
readMemberAttrs(m); |
|
2456 |
} finally { |
|
2457 |
currentOwner = prevOwner; |
|
2458 |
} |
|
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2459 |
setParameters(m, type); |
29551
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2460 |
|
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2461 |
if ((flags & VARARGS) != 0) { |
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2462 |
final Type last = type.getParameterTypes().last(); |
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2463 |
if (last == null || !last.hasTag(ARRAY)) { |
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2464 |
m.flags_field &= ~VARARGS; |
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2465 |
throw badClassFile("malformed.vararg.method", m); |
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2466 |
} |
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2467 |
} |
cad66be66e2e
8071847: java.lang.NullPointerException at com.sun.tools.javac.code.Types.elemtype(Types.java:1870)
sadayapalam
parents:
28333
diff
changeset
|
2468 |
|
10 | 2469 |
return m; |
2470 |
} |
|
2471 |
||
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2472 |
private List<Type> adjustMethodParams(long flags, List<Type> args) { |
51719
e3411e5e473d
8207160: ClassReader::adjustMethodParams can potentially return null if the args list is empty
vromero
parents:
51047
diff
changeset
|
2473 |
if (args.isEmpty()) { |
e3411e5e473d
8207160: ClassReader::adjustMethodParams can potentially return null if the args list is empty
vromero
parents:
51047
diff
changeset
|
2474 |
return args; |
e3411e5e473d
8207160: ClassReader::adjustMethodParams can potentially return null if the args list is empty
vromero
parents:
51047
diff
changeset
|
2475 |
} |
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2476 |
boolean isVarargs = (flags & VARARGS) != 0; |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2477 |
if (isVarargs) { |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2478 |
Type varargsElem = args.last(); |
20249
93f8eae31092
6386236: Please rename com.sun.tools.javac.util.ListBuffer.lb()
alundblad
parents:
20242
diff
changeset
|
2479 |
ListBuffer<Type> adjustedArgs = new ListBuffer<>(); |
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2480 |
for (Type t : args) { |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2481 |
adjustedArgs.append(t != varargsElem ? |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2482 |
t : |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2483 |
((ArrayType)t).makeVarargs()); |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2484 |
} |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2485 |
args = adjustedArgs.toList(); |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2486 |
} |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2487 |
return args.tail; |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2488 |
} |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7632
diff
changeset
|
2489 |
|
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2490 |
/** |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2491 |
* Init the parameter names array. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2492 |
* Parameter names are currently inferred from the names in the |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2493 |
* LocalVariableTable attributes of a Code attribute. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2494 |
* (Note: this means parameter names are currently not available for |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2495 |
* methods without a Code attribute.) |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2496 |
* This method initializes an array in which to store the name indexes |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2497 |
* of parameter names found in LocalVariableTable attributes. It is |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2498 |
* slightly supersized to allow for additional slots with a start_pc of 0. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2499 |
*/ |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2500 |
void initParameterNames(MethodSymbol sym) { |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2501 |
// make allowance for synthetic parameters. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2502 |
final int excessSlots = 4; |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2503 |
int expectedParameterSlots = |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2504 |
Code.width(sym.type.getParameterTypes()) + excessSlots; |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2505 |
if (parameterNameIndices == null |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2506 |
|| parameterNameIndices.length < expectedParameterSlots) { |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2507 |
parameterNameIndices = new int[expectedParameterSlots]; |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2508 |
} else |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2509 |
Arrays.fill(parameterNameIndices, 0); |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2510 |
haveParameterNameIndices = false; |
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2511 |
sawMethodParameters = false; |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2512 |
} |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2513 |
|
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2514 |
/** |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2515 |
* Set the parameters for a method symbol, including any names and |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2516 |
* annotations that were read. |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2517 |
* |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2518 |
* <p>The type of the symbol may have changed while reading the |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2519 |
* method attributes (see the Signature attribute). This may be |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2520 |
* because of generic information or because anonymous synthetic |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2521 |
* parameters were added. The original type (as read from the |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2522 |
* method descriptor) is used to help guess the existence of |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2523 |
* anonymous synthetic parameters. |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2524 |
*/ |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2525 |
void setParameters(MethodSymbol sym, Type jvmType) { |
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2526 |
// If we get parameter names from MethodParameters, then we |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2527 |
// don't need to skip. |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2528 |
int firstParam = 0; |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2529 |
if (!sawMethodParameters) { |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2530 |
firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0; |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2531 |
// the code in readMethod may have skipped the first |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2532 |
// parameter when setting up the MethodType. If so, we |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2533 |
// make a corresponding allowance here for the position of |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2534 |
// the first parameter. Note that this assumes the |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2535 |
// skipped parameter has a width of 1 -- i.e. it is not |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2536 |
// a double width type (long or double.) |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2537 |
if (sym.name == names.init && currentOwner.hasOuterInstance()) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2538 |
// Sometimes anonymous classes don't have an outer |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2539 |
// instance, however, there is no reliable way to tell so |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2540 |
// we never strip this$n |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2541 |
if (!currentOwner.name.isEmpty()) |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2542 |
firstParam += 1; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2543 |
} |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2544 |
|
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2545 |
if (sym.type != jvmType) { |
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2546 |
// reading the method attributes has caused the |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2547 |
// symbol's type to be changed. (i.e. the Signature |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2548 |
// attribute.) This may happen if there are hidden |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2549 |
// (synthetic) parameters in the descriptor, but not |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2550 |
// in the Signature. The position of these hidden |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2551 |
// parameters is unspecified; for now, assume they are |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2552 |
// at the beginning, and so skip over them. The |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2553 |
// primary case for this is two hidden parameters |
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2554 |
// passed into Enum constructors. |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2555 |
int skip = Code.width(jvmType.getParameterTypes()) |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2556 |
- Code.width(sym.type.getParameterTypes()); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2557 |
firstParam += skip; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2558 |
} |
15031
c4fad55a5681
8004727: Add compiler support for parameter reflection
jjg
parents:
14949
diff
changeset
|
2559 |
} |
54514
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2560 |
Set<Name> paramNames = new HashSet<>(); |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2561 |
ListBuffer<VarSymbol> params = new ListBuffer<>(); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2562 |
int nameIndex = firstParam; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2563 |
int annotationIndex = 0; |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2564 |
for (Type t: sym.type.getParameterTypes()) { |
54514
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2565 |
VarSymbol param = parameter(nameIndex, t, sym, paramNames); |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2566 |
params.append(param); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2567 |
if (parameterAnnotations != null) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2568 |
ParameterAnnotations annotations = parameterAnnotations[annotationIndex]; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2569 |
if (annotations != null && annotations.proxies != null |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2570 |
&& !annotations.proxies.isEmpty()) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2571 |
annotate.normal(new AnnotationCompleter(param, annotations.proxies)); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2572 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2573 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2574 |
nameIndex += sawMethodParameters ? 1 : Code.width(t); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2575 |
annotationIndex++; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2576 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2577 |
if (parameterAnnotations != null && parameterAnnotations.length != annotationIndex) { |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2578 |
throw badClassFile("bad.runtime.invisible.param.annotations", sym); |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2579 |
} |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2580 |
Assert.checkNull(sym.params); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2581 |
sym.params = params.toList(); |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2582 |
parameterAnnotations = null; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2583 |
parameterNameIndices = null; |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2584 |
} |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2585 |
|
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2586 |
|
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2587 |
// Returns the name for the parameter at position 'index', either using |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2588 |
// names read from the MethodParameters, or by synthesizing a name that |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2589 |
// is not on the 'exclude' list. |
54514
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2590 |
private VarSymbol parameter(int index, Type t, MethodSymbol owner, Set<Name> exclude) { |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2591 |
long flags = PARAMETER; |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2592 |
Name argName; |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2593 |
if (parameterNameIndices != null && index < parameterNameIndices.length |
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2594 |
&& parameterNameIndices[index] != 0) { |
54514
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2595 |
argName = readName(parameterNameIndices[index]); |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2596 |
flags |= NAME_FILLED; |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2597 |
} else { |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2598 |
String prefix = "arg"; |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2599 |
while (true) { |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2600 |
argName = names.fromString(prefix + exclude.size()); |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2601 |
if (!exclude.contains(argName)) |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2602 |
break; |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2603 |
prefix += "$"; |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2604 |
} |
48344
89f6aa26fd6c
8007720: Names are not loaded correctly for method parameters if the parameters have annotations
cushon
parents:
48081
diff
changeset
|
2605 |
} |
54514
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2606 |
exclude.add(argName); |
b0651dcc8d98
8217047: Provide a way to inject missing parameter names
jlahoda
parents:
54512
diff
changeset
|
2607 |
return new ParamSymbol(flags, argName, t, owner); |
4077
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2608 |
} |
0096541a388e
6889255: javac MethodSymbol throws NPE if ClassReader does not read parameter names correctly
jjg
parents:
4073
diff
changeset
|
2609 |
|
8042 | 2610 |
/** |
2611 |
* skip n bytes |
|
2612 |
*/ |
|
2613 |
void skipBytes(int n) { |
|
2614 |
bp = bp + n; |
|
2615 |
} |
|
2616 |
||
10 | 2617 |
/** Skip a field or method |
2618 |
*/ |
|
2619 |
void skipMember() { |
|
2620 |
bp = bp + 6; |
|
2621 |
char ac = nextChar(); |
|
2622 |
for (int i = 0; i < ac; i++) { |
|
2623 |
bp = bp + 2; |
|
2624 |
int attrLen = nextInt(); |
|
2625 |
bp = bp + attrLen; |
|
2626 |
} |
|
2627 |
} |
|
2628 |
||
36526 | 2629 |
void skipInnerClasses() { |
2630 |
int n = nextChar(); |
|
2631 |
for (int i = 0; i < n; i++) { |
|
2632 |
nextChar(); |
|
2633 |
nextChar(); |
|
2634 |
nextChar(); |
|
2635 |
nextChar(); |
|
2636 |
} |
|
2637 |
} |
|
2638 |
||
10 | 2639 |
/** Enter type variables of this classtype and all enclosing ones in |
2640 |
* `typevars'. |
|
2641 |
*/ |
|
41935
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2642 |
protected void enterTypevars(Symbol sym, Type t) { |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2643 |
if (t.getEnclosingType() != null) { |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2644 |
if (!t.getEnclosingType().hasTag(TypeTag.NONE)) { |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2645 |
enterTypevars(sym.owner, t.getEnclosingType()); |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2646 |
} |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2647 |
} else if (sym.kind == MTH && !sym.isStatic()) { |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2648 |
enterTypevars(sym.owner, sym.owner.type); |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2649 |
} |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2650 |
for (List<Type> xs = t.getTypeArguments(); xs.nonEmpty(); xs = xs.tail) { |
10 | 2651 |
typevars.enter(xs.head.tsym); |
2652 |
} |
|
2653 |
} |
|
2654 |
||
36526 | 2655 |
protected ClassSymbol enterClass(Name name) { |
2656 |
return syms.enterClass(currentModule, name); |
|
2657 |
} |
|
2658 |
||
2659 |
protected ClassSymbol enterClass(Name name, TypeSymbol owner) { |
|
2660 |
return syms.enterClass(currentModule, name, owner); |
|
2661 |
} |
|
2662 |
||
10 | 2663 |
/** Read contents of a given class symbol `c'. Both external and internal |
2664 |
* versions of an inner class are read. |
|
2665 |
*/ |
|
2666 |
void readClass(ClassSymbol c) { |
|
2667 |
ClassType ct = (ClassType)c.type; |
|
2668 |
||
2669 |
// allocate scope for members |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
24895
diff
changeset
|
2670 |
c.members_field = WriteableScope.create(c); |
10 | 2671 |
|
2672 |
// prepare type variable table |
|
2673 |
typevars = typevars.dup(currentOwner); |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13689
diff
changeset
|
2674 |
if (ct.getEnclosingType().hasTag(CLASS)) |
41935
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2675 |
enterTypevars(c.owner, ct.getEnclosingType()); |
10 | 2676 |
|
2677 |
// read flags, or skip if this is an inner class |
|
36526 | 2678 |
long f = nextChar(); |
2679 |
long flags = adjustClassFlags(f); |
|
2680 |
if ((flags & MODULE) == 0) { |
|
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
2681 |
if (c.owner.kind == PCK || c.owner.kind == ERR) c.flags_field = flags; |
36526 | 2682 |
// read own class name and check that it matches |
2683 |
currentModule = c.packge().modle; |
|
2684 |
ClassSymbol self = readClassSymbol(nextChar()); |
|
2685 |
if (c != self) { |
|
2686 |
throw badClassFile("class.file.wrong.class", |
|
2687 |
self.flatname); |
|
2688 |
} |
|
2689 |
} else { |
|
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
2690 |
if (majorVersion < Version.V53.major) { |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
2691 |
throw badClassFile("anachronistic.module.info", |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
2692 |
Integer.toString(majorVersion), |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
2693 |
Integer.toString(minorVersion)); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
2694 |
} |
36526 | 2695 |
c.flags_field = flags; |
41254
08f8dbf7741e
8152911: javac assertion error when compiling overlay sources
jlahoda
parents:
40502
diff
changeset
|
2696 |
currentModule = (ModuleSymbol) c.owner; |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2697 |
int this_class = nextChar(); |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
42497
diff
changeset
|
2698 |
// temp, no check on this_class |
36526 | 2699 |
} |
10 | 2700 |
|
2701 |
// class attributes must be read before class |
|
2702 |
// skip ahead to read class attributes |
|
2703 |
int startbp = bp; |
|
2704 |
nextChar(); |
|
2705 |
char interfaceCount = nextChar(); |
|
2706 |
bp += interfaceCount * 2; |
|
2707 |
char fieldCount = nextChar(); |
|
2708 |
for (int i = 0; i < fieldCount; i++) skipMember(); |
|
2709 |
char methodCount = nextChar(); |
|
2710 |
for (int i = 0; i < methodCount; i++) skipMember(); |
|
2711 |
readClassAttrs(c); |
|
2712 |
||
2713 |
if (readAllOfClassFile) { |
|
2714 |
for (int i = 1; i < poolObj.length; i++) readPool(i); |
|
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14804
diff
changeset
|
2715 |
c.pool = new Pool(poolObj.length, poolObj, types); |
10 | 2716 |
} |
2717 |
||
2718 |
// reset and read rest of classinfo |
|
2719 |
bp = startbp; |
|
2720 |
int n = nextChar(); |
|
39361
cd0aca7db174
8159439: javac throws NPE with Module attribute and super_class != 0
vromero
parents:
39178
diff
changeset
|
2721 |
if ((flags & MODULE) != 0 && n > 0) { |
cd0aca7db174
8159439: javac throws NPE with Module attribute and super_class != 0
vromero
parents:
39178
diff
changeset
|
2722 |
throw badClassFile("module.info.invalid.super.class"); |
cd0aca7db174
8159439: javac throws NPE with Module attribute and super_class != 0
vromero
parents:
39178
diff
changeset
|
2723 |
} |
10 | 2724 |
if (ct.supertype_field == null) |
2725 |
ct.supertype_field = (n == 0) |
|
2726 |
? Type.noType |
|
2727 |
: readClassSymbol(n).erasure(types); |
|
2728 |
n = nextChar(); |
|
2729 |
List<Type> is = List.nil(); |
|
2730 |
for (int i = 0; i < n; i++) { |
|
2731 |
Type _inter = readClassSymbol(nextChar()).erasure(types); |
|
2732 |
is = is.prepend(_inter); |
|
2733 |
} |
|
2734 |
if (ct.interfaces_field == null) |
|
2735 |
ct.interfaces_field = is.reverse(); |
|
2736 |
||
8032 | 2737 |
Assert.check(fieldCount == nextChar()); |
10 | 2738 |
for (int i = 0; i < fieldCount; i++) enterMember(c, readField()); |
8032 | 2739 |
Assert.check(methodCount == nextChar()); |
10 | 2740 |
for (int i = 0; i < methodCount; i++) enterMember(c, readMethod()); |
2741 |
||
2742 |
typevars = typevars.leave(); |
|
2743 |
} |
|
2744 |
||
2745 |
/** Read inner class info. For each inner/outer pair allocate a |
|
2746 |
* member class. |
|
2747 |
*/ |
|
2748 |
void readInnerClasses(ClassSymbol c) { |
|
2749 |
int n = nextChar(); |
|
2750 |
for (int i = 0; i < n; i++) { |
|
2751 |
nextChar(); // skip inner class symbol |
|
2752 |
ClassSymbol outer = readClassSymbol(nextChar()); |
|
2753 |
Name name = readName(nextChar()); |
|
2754 |
if (name == null) name = names.empty; |
|
2755 |
long flags = adjustClassFlags(nextChar()); |
|
2756 |
if (outer != null) { // we have a member class |
|
2757 |
if (name == names.empty) |
|
2758 |
name = names.one; |
|
36526 | 2759 |
ClassSymbol member = enterClass(name, outer); |
10 | 2760 |
if ((flags & STATIC) == 0) { |
2761 |
((ClassType)member.type).setEnclosingType(outer.type); |
|
2762 |
if (member.erasure_field != null) |
|
2763 |
((ClassType)member.erasure_field).setEnclosingType(types.erasure(outer.type)); |
|
2764 |
} |
|
2765 |
if (c == outer) { |
|
2766 |
member.flags_field = flags; |
|
2767 |
enterMember(c, member); |
|
2768 |
} |
|
2769 |
} |
|
2770 |
} |
|
2771 |
} |
|
2772 |
||
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2773 |
/** Read a class definition from the bytes in buf. |
10 | 2774 |
*/ |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2775 |
private void readClassBuffer(ClassSymbol c) throws IOException { |
10 | 2776 |
int magic = nextInt(); |
2777 |
if (magic != JAVA_MAGIC) |
|
2778 |
throw badClassFile("illegal.start.of.class.file"); |
|
2779 |
||
2513
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
2780 |
minorVersion = nextChar(); |
1cbbf23b22f9
6817950: refactor ClassReader to improve attribute handling
jjg
parents:
1260
diff
changeset
|
2781 |
majorVersion = nextChar(); |
48081 | 2782 |
int maxMajor = Version.MAX().major; |
24606
12c0ca21f8dc
8042406: javac.jvm.ClassReader.readClassFile() is using Target to verify valid major versions
ntoda
parents:
24604
diff
changeset
|
2783 |
int maxMinor = Version.MAX().minor; |
10 | 2784 |
if (majorVersion > maxMajor || |
2785 |
majorVersion * 1000 + minorVersion < |
|
35810 | 2786 |
Version.MIN().major * 1000 + Version.MIN().minor) { |
10 | 2787 |
if (majorVersion == (maxMajor + 1)) |
45504
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2788 |
log.warning(Warnings.BigMajorVersion(currentClassFile, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2789 |
majorVersion, |
ea7475564d07
8170326: Inconsistencies between code, compiler.properties and comments
jlahoda
parents:
44183
diff
changeset
|
2790 |
maxMajor)); |
10 | 2791 |
else |
2792 |
throw badClassFile("wrong.version", |
|
2793 |
Integer.toString(majorVersion), |
|
2794 |
Integer.toString(minorVersion), |
|
2795 |
Integer.toString(maxMajor), |
|
2796 |
Integer.toString(maxMinor)); |
|
2797 |
} |
|
35810 | 2798 |
|
49580
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2799 |
if (minorVersion == ClassFile.PREVIEW_MINOR_VERSION) { |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2800 |
if (!preview.isEnabled()) { |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2801 |
log.error(preview.disabledError(currentClassFile, majorVersion)); |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2802 |
} else { |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2803 |
preview.warnPreview(c.classfile, majorVersion); |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2804 |
} |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2805 |
} |
62b908c9f0e6
8199194: Add javac support for preview features
mcimadamore
parents:
49197
diff
changeset
|
2806 |
|
10 | 2807 |
indexPool(); |
2808 |
if (signatureBuffer.length < bp) { |
|
2809 |
int ns = Integer.highestOneBit(bp) << 1; |
|
2810 |
signatureBuffer = new byte[ns]; |
|
2811 |
} |
|
2812 |
readClass(c); |
|
2813 |
} |
|
2814 |
||
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2815 |
public void readClassFile(ClassSymbol c) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2816 |
currentOwner = c; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2817 |
currentClassFile = c.classfile; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2818 |
warnedAttrs.clear(); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2819 |
filling = true; |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2820 |
target = null; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2821 |
repeatable = null; |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2822 |
try { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2823 |
bp = 0; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2824 |
buf = readInputStream(buf, c.classfile.openInputStream()); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2825 |
readClassBuffer(c); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2826 |
if (!missingTypeVariables.isEmpty() && !foundTypeVariables.isEmpty()) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2827 |
List<Type> missing = missingTypeVariables; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2828 |
List<Type> found = foundTypeVariables; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2829 |
missingTypeVariables = List.nil(); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2830 |
foundTypeVariables = List.nil(); |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2831 |
interimUses = List.nil(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
2832 |
interimProvides = List.nil(); |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2833 |
filling = false; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2834 |
ClassType ct = (ClassType)currentOwner.type; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2835 |
ct.supertype_field = |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2836 |
types.subst(ct.supertype_field, missing, found); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2837 |
ct.interfaces_field = |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2838 |
types.subst(ct.interfaces_field, missing, found); |
41935
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2839 |
ct.typarams_field = |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2840 |
types.substBounds(ct.typarams_field, missing, found); |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2841 |
for (List<Type> types = ct.typarams_field; types.nonEmpty(); types = types.tail) { |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2842 |
types.head.tsym.type = types.head; |
b1f606fff3ff
8166635: getEnclosedElements() on package causes BadClassFile error
jlahoda
parents:
41637
diff
changeset
|
2843 |
} |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2844 |
} else if (missingTypeVariables.isEmpty() != |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2845 |
foundTypeVariables.isEmpty()) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2846 |
Name name = missingTypeVariables.head.tsym.name; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2847 |
throw badClassFile("undecl.type.var", name); |
10 | 2848 |
} |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2849 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2850 |
if ((c.flags_field & Flags.ANNOTATION) != 0) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2851 |
c.setAnnotationTypeMetadata(new AnnotationTypeMetadata(c, new CompleterDeproxy(c, target, repeatable))); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2852 |
} else { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2853 |
c.setAnnotationTypeMetadata(AnnotationTypeMetadata.notAnAnnotationType()); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
2854 |
} |
36526 | 2855 |
|
2856 |
if (c == currentModule.module_info) { |
|
2857 |
if (interimUses.nonEmpty() || interimProvides.nonEmpty()) { |
|
2858 |
Assert.check(currentModule.isCompleted()); |
|
2859 |
currentModule.usesProvidesCompleter = |
|
2860 |
new UsesProvidesCompleter(currentModule, interimUses, interimProvides); |
|
2861 |
} else { |
|
2862 |
currentModule.uses = List.nil(); |
|
2863 |
currentModule.provides = List.nil(); |
|
2864 |
} |
|
2865 |
} |
|
43268
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
42973
diff
changeset
|
2866 |
} catch (IOException | ClosedFileSystemException ex) { |
12436ebea906
8147414: java.nio.file.ClosedFileSystemException in javadoc
jjg
parents:
42973
diff
changeset
|
2867 |
throw badClassFile("unable.to.access.file", ex.toString()); |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2868 |
} catch (ArrayIndexOutOfBoundsException ex) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2869 |
throw badClassFile("bad.class.file", c.flatname); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2870 |
} finally { |
36526 | 2871 |
interimUses = List.nil(); |
2872 |
interimProvides = List.nil(); |
|
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2873 |
missingTypeVariables = List.nil(); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2874 |
foundTypeVariables = List.nil(); |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2875 |
filling = false; |
10 | 2876 |
} |
2877 |
} |
|
2878 |
// where |
|
2879 |
private static byte[] readInputStream(byte[] buf, InputStream s) throws IOException { |
|
2880 |
try { |
|
2881 |
buf = ensureCapacity(buf, s.available()); |
|
2882 |
int r = s.read(buf); |
|
2883 |
int bp = 0; |
|
2884 |
while (r != -1) { |
|
2885 |
bp += r; |
|
2886 |
buf = ensureCapacity(buf, bp); |
|
2887 |
r = s.read(buf, bp, buf.length - bp); |
|
2888 |
} |
|
2889 |
return buf; |
|
2890 |
} finally { |
|
2891 |
try { |
|
2892 |
s.close(); |
|
2893 |
} catch (IOException e) { |
|
2894 |
/* Ignore any errors, as this stream may have already |
|
2895 |
* thrown a related exception which is the one that |
|
2896 |
* should be reported. |
|
2897 |
*/ |
|
2898 |
} |
|
2899 |
} |
|
2900 |
} |
|
7842 | 2901 |
/* |
2902 |
* ensureCapacity will increase the buffer as needed, taking note that |
|
2903 |
* the new buffer will always be greater than the needed and never |
|
2904 |
* exactly equal to the needed size or bp. If equal then the read (above) |
|
2905 |
* will infinitely loop as buf.length - bp == 0. |
|
2906 |
*/ |
|
10 | 2907 |
private static byte[] ensureCapacity(byte[] buf, int needed) { |
7842 | 2908 |
if (buf.length <= needed) { |
10 | 2909 |
byte[] old = buf; |
2910 |
buf = new byte[Integer.highestOneBit(needed) << 1]; |
|
2911 |
System.arraycopy(old, 0, buf, 0, old.length); |
|
2912 |
} |
|
2913 |
return buf; |
|
2914 |
} |
|
2915 |
||
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2916 |
/** We can only read a single class file at a time; this |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2917 |
* flag keeps track of when we are currently reading a class |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2918 |
* file. |
10 | 2919 |
*/ |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2920 |
public boolean filling = false; |
10 | 2921 |
|
2922 |
/************************************************************************ |
|
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2923 |
* Adjusting flags |
10 | 2924 |
***********************************************************************/ |
2925 |
||
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2926 |
long adjustFieldFlags(long flags) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2927 |
return flags; |
10 | 2928 |
} |
2929 |
||
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2930 |
long adjustMethodFlags(long flags) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2931 |
if ((flags & ACC_BRIDGE) != 0) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2932 |
flags &= ~ACC_BRIDGE; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2933 |
flags |= BRIDGE; |
24298
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
24068
diff
changeset
|
2934 |
} |
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2935 |
if ((flags & ACC_VARARGS) != 0) { |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2936 |
flags &= ~ACC_VARARGS; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2937 |
flags |= VARARGS; |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2938 |
} |
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2939 |
return flags; |
24298
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
24068
diff
changeset
|
2940 |
} |
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
24068
diff
changeset
|
2941 |
|
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2942 |
long adjustClassFlags(long flags) { |
36526 | 2943 |
if ((flags & ACC_MODULE) != 0) { |
2944 |
flags &= ~ACC_MODULE; |
|
2945 |
flags |= MODULE; |
|
2946 |
} |
|
24604
7f68545b5128
8041422: Split javac ClassReader into ClassReader+ClassFinder
jjg
parents:
24403
diff
changeset
|
2947 |
return flags & ~ACC_SUPER; // SUPER and SYNCHRONIZED bits overloaded |
24298
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
24068
diff
changeset
|
2948 |
} |
cc4f0f71a505
8028196: Javac allows timestamps inside rt.jar to affect compilation when using -sourcepath.
alundblad
parents:
24068
diff
changeset
|
2949 |
|
10 | 2950 |
/** |
2951 |
* A subclass of JavaFileObject for the sourcefile attribute found in a classfile. |
|
2952 |
* The attribute is only the last component of the original filename, so is unlikely |
|
2953 |
* to be valid as is, so operations other than those to access the name throw |
|
2954 |
* UnsupportedOperationException |
|
2955 |
*/ |
|
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
2956 |
private static class SourceFileObject implements JavaFileObject { |
10 | 2957 |
|
2958 |
/** The file's name. |
|
2959 |
*/ |
|
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
2960 |
private final Name name; |
10 | 2961 |
|
54039 | 2962 |
public SourceFileObject(Name name) { |
10 | 2963 |
this.name = name; |
2964 |
} |
|
2965 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2966 |
@Override @DefinedBy(Api.COMPILER) |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2967 |
public URI toUri() { |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2968 |
try { |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2969 |
return new URI(null, name.toString(), null); |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2970 |
} catch (URISyntaxException e) { |
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
2971 |
throw new PathFileObject.CannotCreateUriError(name.toString(), e); |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2972 |
} |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2973 |
} |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2974 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2975 |
@Override @DefinedBy(Api.COMPILER) |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2976 |
public String getName() { |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2977 |
return name.toString(); |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2978 |
} |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2979 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2980 |
@Override @DefinedBy(Api.COMPILER) |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2981 |
public JavaFileObject.Kind getKind() { |
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
2982 |
return BaseFileManager.getKind(getName()); |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2983 |
} |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2984 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2985 |
@Override @DefinedBy(Api.COMPILER) |
10 | 2986 |
public InputStream openInputStream() { |
2987 |
throw new UnsupportedOperationException(); |
|
2988 |
} |
|
2989 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2990 |
@Override @DefinedBy(Api.COMPILER) |
10 | 2991 |
public OutputStream openOutputStream() { |
2992 |
throw new UnsupportedOperationException(); |
|
2993 |
} |
|
2994 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
2995 |
@Override @DefinedBy(Api.COMPILER) |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
2996 |
public CharBuffer getCharContent(boolean ignoreEncodingErrors) { |
10 | 2997 |
throw new UnsupportedOperationException(); |
2998 |
} |
|
2999 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
3000 |
@Override @DefinedBy(Api.COMPILER) |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
3001 |
public Reader openReader(boolean ignoreEncodingErrors) { |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
3002 |
throw new UnsupportedOperationException(); |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
3003 |
} |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
3004 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
3005 |
@Override @DefinedBy(Api.COMPILER) |
10 | 3006 |
public Writer openWriter() { |
3007 |
throw new UnsupportedOperationException(); |
|
3008 |
} |
|
3009 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
3010 |
@Override @DefinedBy(Api.COMPILER) |
10 | 3011 |
public long getLastModified() { |
3012 |
throw new UnsupportedOperationException(); |
|
3013 |
} |
|
3014 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
3015 |
@Override @DefinedBy(Api.COMPILER) |
10 | 3016 |
public boolean delete() { |
3017 |
throw new UnsupportedOperationException(); |
|
3018 |
} |
|
3019 |
||
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3020 |
@Override @DefinedBy(Api.COMPILER) |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3021 |
public boolean isNameCompatible(String simpleName, JavaFileObject.Kind kind) { |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3022 |
return true; // fail-safe mode |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
3023 |
} |
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3782
diff
changeset
|
3024 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
3025 |
@Override @DefinedBy(Api.COMPILER) |
34560
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3026 |
public NestingKind getNestingKind() { |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3027 |
return null; |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3028 |
} |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3029 |
|
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3030 |
@Override @DefinedBy(Api.COMPILER) |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3031 |
public Modifier getAccessLevel() { |
b6a567b677f7
8059976: Convert JavacFileManager to use java.nio.file internally
jjg
parents:
31506
diff
changeset
|
3032 |
return null; |
10 | 3033 |
} |
3034 |
||
4073
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3035 |
/** |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3036 |
* Check if two file objects are equal. |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3037 |
* SourceFileObjects are just placeholder objects for the value of a |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3038 |
* SourceFile attribute, and do not directly represent specific files. |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3039 |
* Two SourceFileObjects are equal if their names are equal. |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3040 |
*/ |
10 | 3041 |
@Override |
3042 |
public boolean equals(Object other) { |
|
4073
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3043 |
if (this == other) |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3044 |
return true; |
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3045 |
|
10 | 3046 |
if (!(other instanceof SourceFileObject)) |
3047 |
return false; |
|
4073
9788f4549740
6838467: JSR199 FileObjects don't obey general contract of equals.
jjg
parents:
3998
diff
changeset
|
3048 |
|
10 | 3049 |
SourceFileObject o = (SourceFileObject) other; |
3050 |
return name.equals(o.name); |
|
3051 |
} |
|
3052 |
||
3053 |
@Override |
|
3054 |
public int hashCode() { |
|
3055 |
return name.hashCode(); |
|
3056 |
} |
|
3057 |
} |
|
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3058 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3059 |
private class CompleterDeproxy implements AnnotationTypeCompleter { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3060 |
ClassSymbol proxyOn; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3061 |
CompoundAnnotationProxy target; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3062 |
CompoundAnnotationProxy repeatable; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3063 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3064 |
public CompleterDeproxy(ClassSymbol c, CompoundAnnotationProxy target, |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3065 |
CompoundAnnotationProxy repeatable) |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3066 |
{ |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3067 |
this.proxyOn = c; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3068 |
this.target = target; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3069 |
this.repeatable = repeatable; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3070 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3071 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3072 |
@Override |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3073 |
public void complete(ClassSymbol sym) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3074 |
Assert.check(proxyOn == sym); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3075 |
Attribute.Compound theTarget = null, theRepeatable = null; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3076 |
AnnotationDeproxy deproxy; |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3077 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3078 |
try { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3079 |
if (target != null) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3080 |
deproxy = new AnnotationDeproxy(proxyOn); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3081 |
theTarget = deproxy.deproxyCompound(target); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3082 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3083 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3084 |
if (repeatable != null) { |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3085 |
deproxy = new AnnotationDeproxy(proxyOn); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3086 |
theRepeatable = deproxy.deproxyCompound(repeatable); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3087 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3088 |
} catch (Exception e) { |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
3089 |
throw new CompletionFailure(sym, |
54339
f69a2f675f19
8221118: Avoid eagerly creating JCDiagnostic for CompletionFailures
ronsh
parents:
54039
diff
changeset
|
3090 |
() -> ClassReader.this.diagFactory.fragment(Fragments.ExceptionMessage(e.getMessage())), |
49197
cc2673fa8c20
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure.
jlahoda
parents:
48826
diff
changeset
|
3091 |
dcfh); |
29842
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3092 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3093 |
|
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3094 |
sym.getAnnotationTypeMetadata().setTarget(theTarget); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3095 |
sym.getAnnotationTypeMetadata().setRepeatable(theRepeatable); |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3096 |
} |
826ac2519523
8031744: Annotations on many Language Model elements are not returned
jjg
parents:
29551
diff
changeset
|
3097 |
} |
36526 | 3098 |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3099 |
private class ProxyType extends Type { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3100 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3101 |
private final byte[] content; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3102 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3103 |
public ProxyType(byte[] content) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3104 |
super(syms.noSymbol, TypeMetadata.EMPTY); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3105 |
this.content = content; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3106 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3107 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3108 |
@Override |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3109 |
public TypeTag getTag() { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3110 |
return TypeTag.NONE; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3111 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3112 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3113 |
@Override |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3114 |
public Type cloneWithMetadata(TypeMetadata metadata) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3115 |
throw new UnsupportedOperationException(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3116 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3117 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3118 |
public Type resolve() { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3119 |
return sigToType(content, 0, content.length); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3120 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3121 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3122 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3123 |
public String toString() { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3124 |
return "<ProxyType>"; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3125 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3126 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3127 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3128 |
|
36526 | 3129 |
private static final class InterimUsesDirective { |
3130 |
public final Name service; |
|
3131 |
||
3132 |
public InterimUsesDirective(Name service) { |
|
3133 |
this.service = service; |
|
3134 |
} |
|
3135 |
||
3136 |
} |
|
3137 |
||
3138 |
private static final class InterimProvidesDirective { |
|
3139 |
public final Name service; |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3140 |
public final List<Name> impls; |
36526 | 3141 |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3142 |
public InterimProvidesDirective(Name service, List<Name> impls) { |
36526 | 3143 |
this.service = service; |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3144 |
this.impls = impls; |
36526 | 3145 |
} |
3146 |
||
3147 |
} |
|
3148 |
||
3149 |
private final class UsesProvidesCompleter implements Completer { |
|
3150 |
private final ModuleSymbol currentModule; |
|
3151 |
private final List<InterimUsesDirective> interimUsesCopy; |
|
3152 |
private final List<InterimProvidesDirective> interimProvidesCopy; |
|
3153 |
||
3154 |
public UsesProvidesCompleter(ModuleSymbol currentModule, List<InterimUsesDirective> interimUsesCopy, List<InterimProvidesDirective> interimProvidesCopy) { |
|
3155 |
this.currentModule = currentModule; |
|
3156 |
this.interimUsesCopy = interimUsesCopy; |
|
3157 |
this.interimProvidesCopy = interimProvidesCopy; |
|
3158 |
} |
|
3159 |
||
3160 |
@Override |
|
3161 |
public void complete(Symbol sym) throws CompletionFailure { |
|
3162 |
ListBuffer<Directive> directives = new ListBuffer<>(); |
|
3163 |
directives.addAll(currentModule.directives); |
|
3164 |
ListBuffer<UsesDirective> uses = new ListBuffer<>(); |
|
3165 |
for (InterimUsesDirective interim : interimUsesCopy) { |
|
3166 |
UsesDirective d = new UsesDirective(syms.enterClass(currentModule, interim.service)); |
|
3167 |
uses.add(d); |
|
3168 |
directives.add(d); |
|
3169 |
} |
|
3170 |
currentModule.uses = uses.toList(); |
|
3171 |
ListBuffer<ProvidesDirective> provides = new ListBuffer<>(); |
|
3172 |
for (InterimProvidesDirective interim : interimProvidesCopy) { |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3173 |
ListBuffer<ClassSymbol> impls = new ListBuffer<>(); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3174 |
for (Name impl : interim.impls) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3175 |
impls.append(syms.enterClass(currentModule, impl)); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3176 |
} |
36526 | 3177 |
ProvidesDirective d = new ProvidesDirective(syms.enterClass(currentModule, interim.service), |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41991
diff
changeset
|
3178 |
impls.toList()); |
36526 | 3179 |
provides.add(d); |
3180 |
directives.add(d); |
|
3181 |
} |
|
3182 |
currentModule.provides = provides.toList(); |
|
3183 |
currentModule.directives = directives.toList(); |
|
3184 |
} |
|
3185 |
} |
|
10 | 3186 |
} |