55 import com.sun.tools.javac.file.BaseFileManager; |
55 import com.sun.tools.javac.file.BaseFileManager; |
56 import com.sun.tools.javac.file.PathFileObject; |
56 import com.sun.tools.javac.file.PathFileObject; |
57 import com.sun.tools.javac.jvm.ClassFile.NameAndType; |
57 import com.sun.tools.javac.jvm.ClassFile.NameAndType; |
58 import com.sun.tools.javac.jvm.ClassFile.Version; |
58 import com.sun.tools.javac.jvm.ClassFile.Version; |
59 import com.sun.tools.javac.main.Option; |
59 import com.sun.tools.javac.main.Option; |
|
60 import com.sun.tools.javac.resources.CompilerProperties.Fragments; |
|
61 import com.sun.tools.javac.resources.CompilerProperties.Warnings; |
60 import com.sun.tools.javac.util.*; |
62 import com.sun.tools.javac.util.*; |
61 import com.sun.tools.javac.util.DefinedBy.Api; |
63 import com.sun.tools.javac.util.DefinedBy.Api; |
62 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
64 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
63 |
65 |
64 import static com.sun.tools.javac.code.Flags.*; |
66 import static com.sun.tools.javac.code.Flags.*; |
277 currentClassFile, |
279 currentClassFile, |
278 diagFactory.fragment(key, args), |
280 diagFactory.fragment(key, args), |
279 diagFactory); |
281 diagFactory); |
280 } |
282 } |
281 |
283 |
282 public ClassFinder.BadEnclosingMethodAttr badEnclosingMethod(Object... args) { |
284 public ClassFinder.BadEnclosingMethodAttr badEnclosingMethod(Symbol sym) { |
283 return new ClassFinder.BadEnclosingMethodAttr ( |
285 return new ClassFinder.BadEnclosingMethodAttr ( |
284 currentOwner.enclClass(), |
286 currentOwner.enclClass(), |
285 currentClassFile, |
287 currentClassFile, |
286 diagFactory.fragment("bad.enclosing.method", args), |
288 diagFactory.fragment(Fragments.BadEnclosingMethod(sym)), |
287 diagFactory); |
289 diagFactory); |
288 } |
290 } |
289 |
291 |
290 /************************************************************************ |
292 /************************************************************************ |
291 * Buffer Access |
293 * Buffer Access |
983 return true; |
985 return true; |
984 |
986 |
985 if (lintClassfile && !warnedAttrs.contains(name)) { |
987 if (lintClassfile && !warnedAttrs.contains(name)) { |
986 JavaFileObject prev = log.useSource(currentClassFile); |
988 JavaFileObject prev = log.useSource(currentClassFile); |
987 try { |
989 try { |
988 log.warning(LintCategory.CLASSFILE, (DiagnosticPosition) null, "future.attr", |
990 log.warning(LintCategory.CLASSFILE, (DiagnosticPosition) null, |
989 name, version.major, version.minor, majorVersion, minorVersion); |
991 Warnings.FutureAttr(name, version.major, version.minor, majorVersion, minorVersion)); |
990 } finally { |
992 } finally { |
991 log.useSource(prev); |
993 log.useSource(prev); |
992 } |
994 } |
993 warnedAttrs.add(name); |
995 warnedAttrs.add(name); |
994 } |
996 } |
2076 // The method wasn't found: emit a warning and recover |
2078 // The method wasn't found: emit a warning and recover |
2077 JavaFileObject prevSource = log.useSource(requestingOwner.classfile); |
2079 JavaFileObject prevSource = log.useSource(requestingOwner.classfile); |
2078 try { |
2080 try { |
2079 if (lintClassfile) { |
2081 if (lintClassfile) { |
2080 if (failure == null) { |
2082 if (failure == null) { |
2081 log.warning("annotation.method.not.found", |
2083 log.warning(Warnings.AnnotationMethodNotFound(container, name)); |
2082 container, |
|
2083 name); |
|
2084 } else { |
2084 } else { |
2085 log.warning("annotation.method.not.found.reason", |
2085 log.warning(Warnings.AnnotationMethodNotFoundReason(container, |
2086 container, |
2086 name, |
2087 name, |
2087 failure.getDetailValue()));//diagnostic, if present |
2088 failure.getDetailValue());//diagnostic, if present |
|
2089 } |
2088 } |
2090 } |
2089 } |
2091 } finally { |
2090 } finally { |
2092 log.useSource(prevSource); |
2091 log.useSource(prevSource); |
2093 } |
2092 } |
2159 catch (CompletionFailure ex) { |
2158 catch (CompletionFailure ex) { |
2160 failure = ex; |
2159 failure = ex; |
2161 } |
2160 } |
2162 if (enumerator == null) { |
2161 if (enumerator == null) { |
2163 if (failure != null) { |
2162 if (failure != null) { |
2164 log.warning("unknown.enum.constant.reason", |
2163 log.warning(Warnings.UnknownEnumConstantReason(currentClassFile, |
2165 currentClassFile, enumTypeSym, proxy.enumerator, |
2164 enumTypeSym, |
2166 failure.getDiagnostic()); |
2165 proxy.enumerator, |
|
2166 failure.getDiagnostic())); |
2167 } else { |
2167 } else { |
2168 log.warning("unknown.enum.constant", |
2168 log.warning(Warnings.UnknownEnumConstant(currentClassFile, |
2169 currentClassFile, enumTypeSym, proxy.enumerator); |
2169 enumTypeSym, |
|
2170 proxy.enumerator)); |
2170 } |
2171 } |
2171 result = new Attribute.Enum(enumTypeSym.type, |
2172 result = new Attribute.Enum(enumTypeSym.type, |
2172 new VarSymbol(0, proxy.enumerator, syms.botType, enumTypeSym)); |
2173 new VarSymbol(0, proxy.enumerator, syms.botType, enumTypeSym)); |
2173 } else { |
2174 } else { |
2174 result = new Attribute.Enum(enumTypeSym.type, enumerator); |
2175 result = new Attribute.Enum(enumTypeSym.type, enumerator); |
2684 int maxMinor = Version.MAX().minor; |
2685 int maxMinor = Version.MAX().minor; |
2685 if (majorVersion > maxMajor || |
2686 if (majorVersion > maxMajor || |
2686 majorVersion * 1000 + minorVersion < |
2687 majorVersion * 1000 + minorVersion < |
2687 Version.MIN().major * 1000 + Version.MIN().minor) { |
2688 Version.MIN().major * 1000 + Version.MIN().minor) { |
2688 if (majorVersion == (maxMajor + 1)) |
2689 if (majorVersion == (maxMajor + 1)) |
2689 log.warning("big.major.version", |
2690 log.warning(Warnings.BigMajorVersion(currentClassFile, |
2690 currentClassFile, |
2691 majorVersion, |
2691 majorVersion, |
2692 maxMajor)); |
2692 maxMajor); |
|
2693 else |
2693 else |
2694 throw badClassFile("wrong.version", |
2694 throw badClassFile("wrong.version", |
2695 Integer.toString(majorVersion), |
2695 Integer.toString(majorVersion), |
2696 Integer.toString(minorVersion), |
2696 Integer.toString(minorVersion), |
2697 Integer.toString(maxMajor), |
2697 Integer.toString(maxMajor), |
2980 if (repeatable != null) { |
2980 if (repeatable != null) { |
2981 deproxy = new AnnotationDeproxy(proxyOn); |
2981 deproxy = new AnnotationDeproxy(proxyOn); |
2982 theRepeatable = deproxy.deproxyCompound(repeatable); |
2982 theRepeatable = deproxy.deproxyCompound(repeatable); |
2983 } |
2983 } |
2984 } catch (Exception e) { |
2984 } catch (Exception e) { |
2985 throw new CompletionFailure(sym, e.getMessage()); |
2985 throw new CompletionFailure(sym, ClassReader.this.diagFactory.fragment(Fragments.ExceptionMessage(e.getMessage()))); |
2986 } |
2986 } |
2987 |
2987 |
2988 sym.getAnnotationTypeMetadata().setTarget(theTarget); |
2988 sym.getAnnotationTypeMetadata().setTarget(theTarget); |
2989 sym.getAnnotationTypeMetadata().setRepeatable(theRepeatable); |
2989 sym.getAnnotationTypeMetadata().setRepeatable(theRepeatable); |
2990 } |
2990 } |