langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Feb 27 18:20:33 2015 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Mon Mar 02 10:41:08 2015 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.parser.Tokens.*;
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
+import com.sun.tools.javac.resources.CompilerProperties;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.*;
@@ -158,6 +159,7 @@
this.allowTypeAnnotations = source.allowTypeAnnotations();
this.allowAnnotationsAfterTypeParams = source.allowAnnotationsAfterTypeParams();
this.allowUnderscoreIdentifier = source.allowUnderscoreIdentifier();
+ this.allowPrivateInterfaceMethods = source.allowPrivateInterfaceMethods();
this.keepDocComments = keepDocComments;
docComments = newDocCommentTable(keepDocComments, fac);
this.keepLineMap = keepLineMap;
@@ -211,6 +213,10 @@
*/
boolean allowStaticInterfaceMethods;
+ /** Switch: should we allow private (instance) methods in interfaces?
+ */
+ boolean allowPrivateInterfaceMethods;
+
/** Switch: should we allow intersection types in cast?
*/
boolean allowIntersectionTypesInCast;
@@ -3487,8 +3493,13 @@
List<JCTypeParameter> typarams,
boolean isInterface, boolean isVoid,
Comment dc) {
- if (isInterface && (mods.flags & Flags.STATIC) != 0) {
- checkStaticInterfaceMethods();
+ if (isInterface) {
+ if ((mods.flags & Flags.STATIC) != 0) {
+ checkStaticInterfaceMethods();
+ }
+ if ((mods.flags & Flags.PRIVATE) != 0) {
+ checkPrivateInterfaceMethods();
+ }
}
JCVariableDecl prevReceiverParam = this.receiverParam;
try {
@@ -4002,6 +4013,12 @@
allowTypeAnnotations = true;
}
}
+ void checkPrivateInterfaceMethods() {
+ if (!allowPrivateInterfaceMethods) {
+ log.error(token.pos, CompilerProperties.Errors.PrivateIntfMethodsNotSupportedInSource(source.name));
+ allowPrivateInterfaceMethods = true;
+ }
+ }
protected void checkAnnotationsAfterTypeParams(int pos) {
if (!allowAnnotationsAfterTypeParams) {
log.error(pos, "annotations.after.type.params.not.supported.in.source", source.name);