src/share/classes/com/sun/tools/javac/parser/JavacParser.java

changeset 2355
4f7d19235357
parent 2211
fb8c59cf26c8
child 2372
7daae506441f
equal deleted inserted replaced
2354:b33835c5d96a 2355:4f7d19235357
159 this.allowMethodReferences = source.allowMethodReferences(); 159 this.allowMethodReferences = source.allowMethodReferences();
160 this.allowDefaultMethods = source.allowDefaultMethods(); 160 this.allowDefaultMethods = source.allowDefaultMethods();
161 this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); 161 this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
162 this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast(); 162 this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast();
163 this.allowTypeAnnotations = source.allowTypeAnnotations(); 163 this.allowTypeAnnotations = source.allowTypeAnnotations();
164 this.allowAnnotationsAfterTypeParams = source.allowAnnotationsAfterTypeParams();
164 this.keepDocComments = keepDocComments; 165 this.keepDocComments = keepDocComments;
165 docComments = newDocCommentTable(keepDocComments, fac); 166 docComments = newDocCommentTable(keepDocComments, fac);
166 this.keepLineMap = keepLineMap; 167 this.keepLineMap = keepLineMap;
167 this.errorTree = F.Erroneous(); 168 this.errorTree = F.Erroneous();
168 endPosTable = newEndPosTable(keepEndPositions); 169 endPosTable = newEndPosTable(keepEndPositions);
251 boolean keepLineMap; 252 boolean keepLineMap;
252 253
253 /** Switch: should we recognize type annotations? 254 /** Switch: should we recognize type annotations?
254 */ 255 */
255 boolean allowTypeAnnotations; 256 boolean allowTypeAnnotations;
257
258 /** Switch: should we allow annotations after the method type parameters?
259 */
260 boolean allowAnnotationsAfterTypeParams;
256 261
257 /** Switch: is "this" allowed as an identifier? 262 /** Switch: is "this" allowed as an identifier?
258 * This is needed to parse receiver types. 263 * This is needed to parse receiver types.
259 */ 264 */
260 boolean allowThisIdent; 265 boolean allowThisIdent;
2018 } 2023 }
2019 2024
2020 /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest ) 2025 /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
2021 */ 2026 */
2022 JCExpression creator(int newpos, List<JCExpression> typeArgs) { 2027 JCExpression creator(int newpos, List<JCExpression> typeArgs) {
2023 List<JCAnnotation> newAnnotations = annotationsOpt(Tag.ANNOTATION); 2028 List<JCAnnotation> newAnnotations = typeAnnotationsOpt();
2024 2029
2025 switch (token.kind) { 2030 switch (token.kind) {
2026 case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT: 2031 case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
2027 case DOUBLE: case BOOLEAN: 2032 case DOUBLE: case BOOLEAN:
2028 if (typeArgs == null) { 2033 if (typeArgs == null) {
3448 illegal(annosAfterParams.head.pos); 3453 illegal(annosAfterParams.head.pos);
3449 type = to(F.at(pos).TypeIdent(TypeTag.VOID)); 3454 type = to(F.at(pos).TypeIdent(TypeTag.VOID));
3450 nextToken(); 3455 nextToken();
3451 } else { 3456 } else {
3452 if (annosAfterParams.nonEmpty()) { 3457 if (annosAfterParams.nonEmpty()) {
3458 checkAnnotationsAfterTypeParams(annosAfterParams.head.pos);
3453 mods.annotations = mods.annotations.appendList(annosAfterParams); 3459 mods.annotations = mods.annotations.appendList(annosAfterParams);
3454 if (mods.pos == Position.NOPOS) 3460 if (mods.pos == Position.NOPOS)
3455 mods.pos = mods.annotations.head.pos; 3461 mods.pos = mods.annotations.head.pos;
3456 } 3462 }
3457 // method returns types are un-annotated types 3463 // method returns types are un-annotated types
4039 if (!allowTypeAnnotations) { 4045 if (!allowTypeAnnotations) {
4040 log.error(token.pos, "type.annotations.not.supported.in.source", source.name); 4046 log.error(token.pos, "type.annotations.not.supported.in.source", source.name);
4041 allowTypeAnnotations = true; 4047 allowTypeAnnotations = true;
4042 } 4048 }
4043 } 4049 }
4050 void checkAnnotationsAfterTypeParams(int pos) {
4051 if (!allowAnnotationsAfterTypeParams) {
4052 log.error(pos, "annotations.after.type.params.not.supported.in.source", source.name);
4053 allowAnnotationsAfterTypeParams = true;
4054 }
4055 }
4044 4056
4045 /* 4057 /*
4046 * a functional source tree and end position mappings 4058 * a functional source tree and end position mappings
4047 */ 4059 */
4048 protected static class SimpleEndPosTable extends AbstractEndPosTable { 4060 protected static class SimpleEndPosTable extends AbstractEndPosTable {

mercurial