88 * This code and its internal interfaces are subject to change or
89 * deletion without notice.</b>
90 */
91 public class ClassReader {
92 /** The context key for the class reader. */
93 protected static final Context.Key<ClassReader> classReaderKey = new Context.Key<>();
94
95 public static final int INITIAL_BUFFER_SIZE = 0x0fff0;
96
97 private final Annotate annotate;
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
108 /** Switch: allow simplified varargs.
109 */
110 boolean allowSimplifiedVarargs;
111
112 /** Switch: allow modules.
113 */
114 boolean allowModules;
115
116 /** Lint option: warn about classfile issues
117 */
118 boolean lintClassfile;
119
120 /** Switch: preserve parameter names from the variable table.
121 */
122 public boolean saveParameterNames;
123
124 /**
125 * The currently selected profile.
126 */
127 public final Profile profile;
128
129 /** The log to use for verbose output
130 */
131 final Log log;
259 /** Construct a new class reader. */
260 protected ClassReader(Context context) {
261 context.put(classReaderKey, this);
262 annotate = Annotate.instance(context);
263 names = Names.instance(context);
264 syms = Symtab.instance(context);
265 types = Types.instance(context);
266 fileManager = context.get(JavaFileManager.class);
267 if (fileManager == null)
268 throw new AssertionError("FileManager initialization error");
269 diagFactory = JCDiagnostic.Factory.instance(context);
270 dcfh = DeferredCompletionFailureHandler.instance(context);
271
272 log = Log.instance(context);
273
274 Options options = Options.instance(context);
275 verbose = options.isSet(Option.VERBOSE);
276
277 Source source = Source.instance(context);
278 preview = Preview.instance(context);
279 allowSimplifiedVarargs = Feature.SIMPLIFIED_VARARGS.allowedInSource(source);
280 allowModules = Feature.MODULES.allowedInSource(source);
281
282 saveParameterNames = options.isSet(PARAMETERS);
283
284 profile = Profile.instance(context);
285
286 typevars = WriteableScope.create(syms.noSymbol);
287
288 lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE);
289
290 initAttributeReaders();
291 }
292
293 /** Add member to class unless it is synthetic.
294 */
295 private void enterMember(ClassSymbol c, Symbol sym) {
296 // Synthetic members are not entered -- reason lost to history (optimization?).
297 // Lambda methods must be entered because they may have inner classes (which reference them)
298 if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC || sym.name.startsWith(names.lambda))
299 c.members_field.enter(sym);
|
88 * This code and its internal interfaces are subject to change or
89 * deletion without notice.</b>
90 */
91 public class ClassReader {
92 /** The context key for the class reader. */
93 protected static final Context.Key<ClassReader> classReaderKey = new Context.Key<>();
94
95 public static final int INITIAL_BUFFER_SIZE = 0x0fff0;
96
97 private final Annotate annotate;
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
108 /** Switch: allow modules.
109 */
110 boolean allowModules;
111
112 /** Lint option: warn about classfile issues
113 */
114 boolean lintClassfile;
115
116 /** Switch: preserve parameter names from the variable table.
117 */
118 public boolean saveParameterNames;
119
120 /**
121 * The currently selected profile.
122 */
123 public final Profile profile;
124
125 /** The log to use for verbose output
126 */
127 final Log log;
255 /** Construct a new class reader. */
256 protected ClassReader(Context context) {
257 context.put(classReaderKey, this);
258 annotate = Annotate.instance(context);
259 names = Names.instance(context);
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");
265 diagFactory = JCDiagnostic.Factory.instance(context);
266 dcfh = DeferredCompletionFailureHandler.instance(context);
267
268 log = Log.instance(context);
269
270 Options options = Options.instance(context);
271 verbose = options.isSet(Option.VERBOSE);
272
273 Source source = Source.instance(context);
274 preview = Preview.instance(context);
275 allowModules = Feature.MODULES.allowedInSource(source);
276
277 saveParameterNames = options.isSet(PARAMETERS);
278
279 profile = Profile.instance(context);
280
281 typevars = WriteableScope.create(syms.noSymbol);
282
283 lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE);
284
285 initAttributeReaders();
286 }
287
288 /** Add member to class unless it is synthetic.
289 */
290 private void enterMember(ClassSymbol c, Symbol sym) {
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))
294 c.members_field.enter(sym);
|