113 |
113 |
114 /** Lint option: warn about classfile issues |
114 /** Lint option: warn about classfile issues |
115 */ |
115 */ |
116 boolean lintClassfile; |
116 boolean lintClassfile; |
117 |
117 |
|
118 /** Switch: allow default methods |
|
119 */ |
|
120 boolean allowDefaultMethods; |
118 |
121 |
119 /** Switch: preserve parameter names from the variable table. |
122 /** Switch: preserve parameter names from the variable table. |
120 */ |
123 */ |
121 public boolean saveParameterNames; |
124 public boolean saveParameterNames; |
122 |
125 |
277 Source source = Source.instance(context); |
280 Source source = Source.instance(context); |
278 allowGenerics = source.allowGenerics(); |
281 allowGenerics = source.allowGenerics(); |
279 allowVarargs = source.allowVarargs(); |
282 allowVarargs = source.allowVarargs(); |
280 allowAnnotations = source.allowAnnotations(); |
283 allowAnnotations = source.allowAnnotations(); |
281 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); |
284 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); |
|
285 allowDefaultMethods = source.allowDefaultMethods(); |
282 saveParameterNames = options.isSet("save-parameter-names"); |
286 saveParameterNames = options.isSet("save-parameter-names"); |
283 cacheCompletionFailure = options.isUnset("dev"); |
287 cacheCompletionFailure = options.isUnset("dev"); |
284 preferSource = "source".equals(options.get("-Xprefer")); |
288 preferSource = "source".equals(options.get("-Xprefer")); |
285 |
289 |
286 completionFailureName = |
290 completionFailureName = |
935 AttributeReader[] readers = { |
939 AttributeReader[] readers = { |
936 // v45.3 attributes |
940 // v45.3 attributes |
937 |
941 |
938 new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) { |
942 new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) { |
939 protected void read(Symbol sym, int attrLen) { |
943 protected void read(Symbol sym, int attrLen) { |
|
944 if (currentOwner.isInterface() && |
|
945 (sym.flags_field & ABSTRACT) == 0 && !name.equals(names.clinit)) { |
|
946 if (majorVersion > Target.JDK1_8.majorVersion || |
|
947 //todo replace with Target.Version when available |
|
948 (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) { |
|
949 currentOwner.flags_field |= DEFAULT; |
|
950 sym.flags_field |= DEFAULT | ABSTRACT; |
|
951 } else { |
|
952 //protect against ill-formed classfiles |
|
953 throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile"); |
|
954 } |
|
955 } |
940 if (readAllOfClassFile || saveParameterNames) |
956 if (readAllOfClassFile || saveParameterNames) |
941 ((MethodSymbol)sym).code = readCode(sym); |
957 ((MethodSymbol)sym).code = readCode(sym); |
942 else |
958 else |
943 bp = bp + attrLen; |
959 bp = bp + attrLen; |
944 } |
960 } |