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

changeset 1513
cf84b07a82db
parent 1511
c7c41a044e7c
child 1521
71f35e4b93a5
equal deleted inserted replaced
1512:b12ffdfa1341 1513:cf84b07a82db
122 this.allowMulticatch = source.allowMulticatch(); 122 this.allowMulticatch = source.allowMulticatch();
123 this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true); 123 this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
124 this.allowLambda = source.allowLambda(); 124 this.allowLambda = source.allowLambda();
125 this.allowMethodReferences = source.allowMethodReferences(); 125 this.allowMethodReferences = source.allowMethodReferences();
126 this.allowDefaultMethods = source.allowDefaultMethods(); 126 this.allowDefaultMethods = source.allowDefaultMethods();
127 this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
127 this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast(); 128 this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast();
128 this.keepDocComments = keepDocComments; 129 this.keepDocComments = keepDocComments;
129 docComments = newDocCommentTable(keepDocComments, fac); 130 docComments = newDocCommentTable(keepDocComments, fac);
130 this.keepLineMap = keepLineMap; 131 this.keepLineMap = keepLineMap;
131 this.errorTree = F.Erroneous(); 132 this.errorTree = F.Erroneous();
195 boolean allowMethodReferences; 196 boolean allowMethodReferences;
196 197
197 /** Switch: should we allow default methods in interfaces? 198 /** Switch: should we allow default methods in interfaces?
198 */ 199 */
199 boolean allowDefaultMethods; 200 boolean allowDefaultMethods;
201
202 /** Switch: should we allow static methods in interfaces?
203 */
204 boolean allowStaticInterfaceMethods;
200 205
201 /** Switch: should we allow intersection types in cast? 206 /** Switch: should we allow intersection types in cast?
202 */ 207 */
203 boolean allowIntersectionTypesInCast; 208 boolean allowIntersectionTypesInCast;
204 209
3091 JCExpression type, 3096 JCExpression type,
3092 Name name, 3097 Name name,
3093 List<JCTypeParameter> typarams, 3098 List<JCTypeParameter> typarams,
3094 boolean isInterface, boolean isVoid, 3099 boolean isInterface, boolean isVoid,
3095 Comment dc) { 3100 Comment dc) {
3101 if (isInterface && (mods.flags & Flags.STATIC) != 0) {
3102 checkStaticInterfaceMethods();
3103 }
3096 List<JCVariableDecl> params = formalParameters(); 3104 List<JCVariableDecl> params = formalParameters();
3097 if (!isVoid) type = bracketsOpt(type); 3105 if (!isVoid) type = bracketsOpt(type);
3098 List<JCExpression> thrown = List.nil(); 3106 List<JCExpression> thrown = List.nil();
3099 if (token.kind == THROWS) { 3107 if (token.kind == THROWS) {
3100 nextToken(); 3108 nextToken();
3492 if (!allowIntersectionTypesInCast) { 3500 if (!allowIntersectionTypesInCast) {
3493 log.error(token.pos, "intersection.types.in.cast.not.supported.in.source", source.name); 3501 log.error(token.pos, "intersection.types.in.cast.not.supported.in.source", source.name);
3494 allowIntersectionTypesInCast = true; 3502 allowIntersectionTypesInCast = true;
3495 } 3503 }
3496 } 3504 }
3505 void checkStaticInterfaceMethods() {
3506 if (!allowStaticInterfaceMethods) {
3507 log.error(token.pos, "static.intf.methods.not.supported.in.source", source.name);
3508 allowStaticInterfaceMethods = true;
3509 }
3510 }
3497 3511
3498 /* 3512 /*
3499 * a functional source tree and end position mappings 3513 * a functional source tree and end position mappings
3500 */ 3514 */
3501 protected class SimpleEndPosTable extends AbstractEndPosTable { 3515 protected class SimpleEndPosTable extends AbstractEndPosTable {

mercurial