< prev index next >

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

Print this page
rev 2977 : JDK-8058150


1300         bp += code_length;
1301         final char exception_table_length = nextChar();
1302         bp += exception_table_length * 8;
1303         readMemberAttrs(owner);
1304         return null;
1305     }
1306 
1307 /************************************************************************
1308  * Reading Java-language annotations
1309  ***********************************************************************/
1310 
1311     /** Attach annotations.
1312      */
1313     void attachAnnotations(final Symbol sym) {
1314         int numAttributes = nextChar();
1315         if (numAttributes != 0) {
1316             ListBuffer<CompoundAnnotationProxy> proxies = new ListBuffer<>();
1317             for (int i = 0; i<numAttributes; i++) {
1318                 CompoundAnnotationProxy proxy = readCompoundAnnotation();
1319 














1320                 if (proxy.type.tsym == syms.annotationTargetType.tsym) {
1321                     target = proxy;
1322                 } else if (proxy.type.tsym == syms.repeatableType.tsym) {
1323                     repeatable = proxy;
1324                 }
1325 
1326                 proxies.append(proxy);
1327             }

1328             annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
1329         }
1330     }
1331 
1332     /** Attach parameter annotations.
1333      */
1334     void attachParameterAnnotations(final Symbol method) {
1335         final MethodSymbol meth = (MethodSymbol)method;
1336         int numParameters = buf[bp++] & 0xFF;
1337         List<VarSymbol> parameters = meth.params();
1338         int pnum = 0;
1339         while (parameters.tail != null) {
1340             attachAnnotations(parameters.head);
1341             parameters = parameters.tail;
1342             pnum++;
1343         }
1344         if (pnum != numParameters) {
1345             throw badClassFile("bad.runtime.invisible.param.annotations", meth);
1346         }
1347     }




1300         bp += code_length;
1301         final char exception_table_length = nextChar();
1302         bp += exception_table_length * 8;
1303         readMemberAttrs(owner);
1304         return null;
1305     }
1306 
1307 /************************************************************************
1308  * Reading Java-language annotations
1309  ***********************************************************************/
1310 
1311     /** Attach annotations.
1312      */
1313     void attachAnnotations(final Symbol sym) {
1314         int numAttributes = nextChar();
1315         if (numAttributes != 0) {
1316             ListBuffer<CompoundAnnotationProxy> proxies = new ListBuffer<>();
1317             for (int i = 0; i<numAttributes; i++) {
1318                 CompoundAnnotationProxy proxy = readCompoundAnnotation();
1319 
1320                 if (proxy.type.tsym == syms.proprietaryType.tsym)
1321                     sym.flags_field |= PROPRIETARY;
1322                 else if (proxy.type.tsym == syms.profileType.tsym) {
1323                     if (profile != Profile.DEFAULT) {
1324                         for (Pair<Name,Attribute> v: proxy.values) {
1325                             if (v.fst == names.value && v.snd instanceof Attribute.Constant) {
1326                                 Attribute.Constant c = (Attribute.Constant) v.snd;
1327                                 if (c.type == syms.intType && ((Integer) c.value) > profile.value) {
1328                                     sym.flags_field |= NOT_IN_PROFILE;
1329                                 }
1330                             }
1331                         }
1332                     }
1333                 } else {
1334                     if (proxy.type.tsym == syms.annotationTargetType.tsym) {
1335                         target = proxy;
1336                     } else if (proxy.type.tsym == syms.repeatableType.tsym) {
1337                         repeatable = proxy;
1338                     }
1339 
1340                     proxies.append(proxy);
1341                 }
1342             }
1343             annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
1344         }
1345     }
1346 
1347     /** Attach parameter annotations.
1348      */
1349     void attachParameterAnnotations(final Symbol method) {
1350         final MethodSymbol meth = (MethodSymbol)method;
1351         int numParameters = buf[bp++] & 0xFF;
1352         List<VarSymbol> parameters = meth.params();
1353         int pnum = 0;
1354         while (parameters.tail != null) {
1355             attachAnnotations(parameters.head);
1356             parameters = parameters.tail;
1357             pnum++;
1358         }
1359         if (pnum != numParameters) {
1360             throw badClassFile("bad.runtime.invisible.param.annotations", meth);
1361         }
1362     }


< prev index next >