src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File langtools Sdiff src/share/classes/com/sun/tools/javac/jvm

src/share/classes/com/sun/tools/javac/jvm/ClassReader.java

Print this page




 117 
 118     /** Switch: allow default methods
 119      */
 120     boolean allowDefaultMethods;
 121 
 122     /** Switch: preserve parameter names from the variable table.
 123      */
 124     public boolean saveParameterNames;
 125 
 126     /**
 127      * Switch: cache completion failures unless -XDdev is used
 128      */
 129     private boolean cacheCompletionFailure;
 130 
 131     /**
 132      * Switch: prefer source files instead of newer when both source
 133      * and class are available
 134      **/
 135     public boolean preferSource;
 136 





 137     /** The log to use for verbose output
 138      */
 139     final Log log;
 140 
 141     /** The symbol table. */
 142     Symtab syms;
 143 
 144     Types types;
 145 
 146     /** The name table. */
 147     final Names names;
 148 
 149     /** Force a completion failure on this name
 150      */
 151     final Name completionFailureName;
 152 
 153     /** Access to files
 154      */
 155     private final JavaFileManager fileManager;
 156 


 267      *  definitive classreader for this invocation.
 268      */
 269     protected ClassReader(Context context, boolean definitive) {
 270         if (definitive) context.put(classReaderKey, this);
 271 
 272         names = Names.instance(context);
 273         syms = Symtab.instance(context);
 274         types = Types.instance(context);
 275         fileManager = context.get(JavaFileManager.class);
 276         if (fileManager == null)
 277             throw new AssertionError("FileManager initialization error");
 278         diagFactory = JCDiagnostic.Factory.instance(context);
 279 
 280         init(syms, definitive);
 281         log = Log.instance(context);
 282 
 283         Options options = Options.instance(context);
 284         annotate = Annotate.instance(context);
 285         verbose        = options.isSet(VERBOSE);
 286         checkClassFile = options.isSet("-checkclassfile");

 287         Source source = Source.instance(context);
 288         allowGenerics    = source.allowGenerics();
 289         allowVarargs     = source.allowVarargs();
 290         allowAnnotations = source.allowAnnotations();
 291         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
 292         allowDefaultMethods = source.allowDefaultMethods();

 293         saveParameterNames = options.isSet("save-parameter-names");
 294         cacheCompletionFailure = options.isUnset("dev");
 295         preferSource = "source".equals(options.get("-Xprefer"));
 296 


 297         completionFailureName =
 298             options.isSet("failcomplete")
 299             ? names.fromString(options.get("failcomplete"))
 300             : null;
 301 
 302         typevars = new Scope(syms.noSymbol);
 303 
 304         lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE);
 305 
 306         initAttributeReaders();
 307     }
 308 
 309     /** Add member to class unless it is synthetic.
 310      */
 311     private void enterMember(ClassSymbol c, Symbol sym) {
 312         if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC)
 313             c.members_field.enter(sym);
 314     }
 315 
 316 /************************************************************************


1340         bp += exception_table_length * 8;
1341         readMemberAttrs(owner);
1342         return null;
1343     }
1344 
1345 /************************************************************************
1346  * Reading Java-language annotations
1347  ***********************************************************************/
1348 
1349     /** Attach annotations.
1350      */
1351     void attachAnnotations(final Symbol sym) {
1352         int numAttributes = nextChar();
1353         if (numAttributes != 0) {
1354             ListBuffer<CompoundAnnotationProxy> proxies =
1355                 new ListBuffer<CompoundAnnotationProxy>();
1356             for (int i = 0; i<numAttributes; i++) {
1357                 CompoundAnnotationProxy proxy = readCompoundAnnotation();
1358                 if (proxy.type.tsym == syms.proprietaryType.tsym)
1359                     sym.flags_field |= PROPRIETARY;
1360                 else











1361                     proxies.append(proxy);
1362             }
1363             annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
1364         }
1365     }
1366 
1367     /** Attach parameter annotations.
1368      */
1369     void attachParameterAnnotations(final Symbol method) {
1370         final MethodSymbol meth = (MethodSymbol)method;
1371         int numParameters = buf[bp++] & 0xFF;
1372         List<VarSymbol> parameters = meth.params();
1373         int pnum = 0;
1374         while (parameters.tail != null) {
1375             attachAnnotations(parameters.head);
1376             parameters = parameters.tail;
1377             pnum++;
1378         }
1379         if (pnum != numParameters) {
1380             throw badClassFile("bad.runtime.invisible.param.annotations", meth);




 117 
 118     /** Switch: allow default methods
 119      */
 120     boolean allowDefaultMethods;
 121 
 122     /** Switch: preserve parameter names from the variable table.
 123      */
 124     public boolean saveParameterNames;
 125 
 126     /**
 127      * Switch: cache completion failures unless -XDdev is used
 128      */
 129     private boolean cacheCompletionFailure;
 130 
 131     /**
 132      * Switch: prefer source files instead of newer when both source
 133      * and class are available
 134      **/
 135     public boolean preferSource;
 136     
 137     /**
 138      * The currently selected profile.
 139      */
 140     public final Profile profile;
 141 
 142     /** The log to use for verbose output
 143      */
 144     final Log log;
 145 
 146     /** The symbol table. */
 147     Symtab syms;
 148 
 149     Types types;
 150 
 151     /** The name table. */
 152     final Names names;
 153 
 154     /** Force a completion failure on this name
 155      */
 156     final Name completionFailureName;
 157 
 158     /** Access to files
 159      */
 160     private final JavaFileManager fileManager;
 161 


 272      *  definitive classreader for this invocation.
 273      */
 274     protected ClassReader(Context context, boolean definitive) {
 275         if (definitive) context.put(classReaderKey, this);
 276 
 277         names = Names.instance(context);
 278         syms = Symtab.instance(context);
 279         types = Types.instance(context);
 280         fileManager = context.get(JavaFileManager.class);
 281         if (fileManager == null)
 282             throw new AssertionError("FileManager initialization error");
 283         diagFactory = JCDiagnostic.Factory.instance(context);
 284 
 285         init(syms, definitive);
 286         log = Log.instance(context);
 287 
 288         Options options = Options.instance(context);
 289         annotate = Annotate.instance(context);
 290         verbose        = options.isSet(VERBOSE);
 291         checkClassFile = options.isSet("-checkclassfile");
 292         
 293         Source source = Source.instance(context);
 294         allowGenerics    = source.allowGenerics();
 295         allowVarargs     = source.allowVarargs();
 296         allowAnnotations = source.allowAnnotations();
 297         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
 298         allowDefaultMethods = source.allowDefaultMethods();
 299         
 300         saveParameterNames = options.isSet("save-parameter-names");
 301         cacheCompletionFailure = options.isUnset("dev");
 302         preferSource = "source".equals(options.get("-Xprefer"));
 303         
 304         profile = Profile.instance(context);
 305 
 306         completionFailureName =
 307             options.isSet("failcomplete")
 308             ? names.fromString(options.get("failcomplete"))
 309             : null;
 310 
 311         typevars = new Scope(syms.noSymbol);
 312 
 313         lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE);
 314 
 315         initAttributeReaders();
 316     }
 317 
 318     /** Add member to class unless it is synthetic.
 319      */
 320     private void enterMember(ClassSymbol c, Symbol sym) {
 321         if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC)
 322             c.members_field.enter(sym);
 323     }
 324 
 325 /************************************************************************


1349         bp += exception_table_length * 8;
1350         readMemberAttrs(owner);
1351         return null;
1352     }
1353 
1354 /************************************************************************
1355  * Reading Java-language annotations
1356  ***********************************************************************/
1357 
1358     /** Attach annotations.
1359      */
1360     void attachAnnotations(final Symbol sym) {
1361         int numAttributes = nextChar();
1362         if (numAttributes != 0) {
1363             ListBuffer<CompoundAnnotationProxy> proxies =
1364                 new ListBuffer<CompoundAnnotationProxy>();
1365             for (int i = 0; i<numAttributes; i++) {
1366                 CompoundAnnotationProxy proxy = readCompoundAnnotation();
1367                 if (proxy.type.tsym == syms.proprietaryType.tsym)
1368                     sym.flags_field |= PROPRIETARY;
1369                 else if (proxy.type.tsym == syms.profileType.tsym) {
1370                     if (profile != Profile.DEFAULT) {
1371                         for (Pair<Name,Attribute> v: proxy.values) {
1372                             if (v.fst == names.value && v.snd instanceof Attribute.Constant) {
1373                                 Attribute.Constant c = (Attribute.Constant) v.snd;
1374                                 if (c.type == syms.intType && ((Integer) c.value) > profile.value) {
1375                                     sym.flags_field |= NOT_IN_PROFILE;
1376                                 }
1377                             }
1378                         }
1379                     }
1380                 } else
1381                     proxies.append(proxy);
1382             }
1383             annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
1384         }
1385     }
1386 
1387     /** Attach parameter annotations.
1388      */
1389     void attachParameterAnnotations(final Symbol method) {
1390         final MethodSymbol meth = (MethodSymbol)method;
1391         int numParameters = buf[bp++] & 0xFF;
1392         List<VarSymbol> parameters = meth.params();
1393         int pnum = 0;
1394         while (parameters.tail != null) {
1395             attachAnnotations(parameters.head);
1396             parameters = parameters.tail;
1397             pnum++;
1398         }
1399         if (pnum != numParameters) {
1400             throw badClassFile("bad.runtime.invisible.param.annotations", meth);


src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File