Sat, 26 Mar 2011 00:11:34 -0700
Merge
1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java Thu Mar 24 11:20:59 2011 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java Sat Mar 26 00:11:34 2011 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -305,11 +305,7 @@ 1.11 tr.addContent(tdFirst); 1.12 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 1.13 tdLast.addStyle(HtmlStyle.colLast); 1.14 - if (pkg != null) { 1.15 - addSummaryComment(pkg, tdLast); 1.16 - } else { 1.17 - tdLast.addContent(getSpace()); 1.18 - } 1.19 + addSummaryComment(pkg, tdLast); 1.20 tr.addContent(tdLast); 1.21 tbody.addContent(tr); 1.22 } 1.23 @@ -355,10 +351,7 @@ 1.24 contentTree.addContent(tdFirst); 1.25 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 1.26 tdLast.addStyle(HtmlStyle.colLast); 1.27 - if (pkg != null) 1.28 - addSummaryComment(pkg, tdLast); 1.29 - else 1.30 - tdLast.addContent(getSpace()); 1.31 + addSummaryComment(pkg, tdLast); 1.32 contentTree.addContent(tdLast); 1.33 } 1.34
2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java Thu Mar 24 11:20:59 2011 -0700 2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java Sat Mar 26 00:11:34 2011 -0700 2.3 @@ -283,23 +283,32 @@ 2.4 Content framePara = HtmlTree.P(line26); 2.5 liFrame.addContent(framePara); 2.6 ul.addContent(liFrame); 2.7 + Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, 2.8 + getResource("doclet.All_Classes")); 2.9 + Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead); 2.10 + Content line27 = getResource("doclet.Help_line_27", 2.11 + getHyperLinkString("allclasses-noframe.html", 2.12 + configuration.getText("doclet.All_Classes"))); 2.13 + Content allclassesPara = HtmlTree.P(line27); 2.14 + liAllClasses.addContent(allclassesPara); 2.15 + ul.addContent(liAllClasses); 2.16 Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, 2.17 getResource("doclet.Serialized_Form")); 2.18 Content liSerial = HtmlTree.LI(HtmlStyle.blockList, sHead); 2.19 - Content line27 = getResource("doclet.Help_line_27"); 2.20 - Content serialPara = HtmlTree.P(line27); 2.21 + Content line28 = getResource("doclet.Help_line_28"); 2.22 + Content serialPara = HtmlTree.P(line28); 2.23 liSerial.addContent(serialPara); 2.24 ul.addContent(liSerial); 2.25 Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, 2.26 getResource("doclet.Constants_Summary")); 2.27 Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead); 2.28 - Content line28 = getResource("doclet.Help_line_28"); 2.29 - Content constPara = HtmlTree.P(line28); 2.30 + Content line29 = getResource("doclet.Help_line_29"); 2.31 + Content constPara = HtmlTree.P(line29); 2.32 liConst.addContent(constPara); 2.33 ul.addContent(liConst); 2.34 Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul); 2.35 - Content line29 = HtmlTree.EM(getResource("doclet.Help_line_29")); 2.36 - divContent.addContent(line29); 2.37 + Content line30 = HtmlTree.EM(getResource("doclet.Help_line_30")); 2.38 + divContent.addContent(line30); 2.39 contentTree.addContent(divContent); 2.40 } 2.41
3.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java Thu Mar 24 11:20:59 2011 -0700 3.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java Sat Mar 26 00:11:34 2011 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -246,10 +246,7 @@ 3.11 contentTree.addContent(tdFirst); 3.12 HtmlTree tdLast = new HtmlTree(HtmlTag.TD); 3.13 tdLast.addStyle(HtmlStyle.colLast); 3.14 - if (pkg != null) 3.15 - addSummaryComment(pkg, tdLast); 3.16 - else 3.17 - tdLast.addContent(getSpace()); 3.18 + addSummaryComment(pkg, tdLast); 3.19 contentTree.addContent(tdLast); 3.20 } 3.21
4.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Thu Mar 24 11:20:59 2011 -0700 4.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Sat Mar 26 00:11:34 2011 -0700 4.3 @@ -167,7 +167,7 @@ 4.4 doclet.Help_line_1=How This API Document Is Organized 4.5 doclet.Help_line_2=This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows. 4.6 doclet.Help_line_3=The {0} page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages. 4.7 -doclet.Help_line_4=Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories: 4.8 +doclet.Help_line_4=Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories: 4.9 doclet.Help_line_5=Class/Interface 4.10 doclet.Help_line_6=Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions: 4.11 doclet.Help_line_7=Class inheritance diagram 4.12 @@ -190,9 +190,10 @@ 4.13 doclet.Help_line_24=These links take you to the next or previous class, interface, package, or related page. 4.14 doclet.Help_line_25=Frames/No Frames 4.15 doclet.Help_line_26=These links show and hide the HTML frames. All pages are available with or without frames. 4.16 -doclet.Help_line_27=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. 4.17 -doclet.Help_line_28=The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values. 4.18 -doclet.Help_line_29=This help file applies to API documentation generated using the standard doclet. 4.19 +doclet.Help_line_27=The {0} link shows all classes and interfaces except non-static nested types. 4.20 +doclet.Help_line_28=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. 4.21 +doclet.Help_line_29=The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values. 4.22 +doclet.Help_line_30=This help file applies to API documentation generated using the standard doclet. 4.23 doclet.Help_enum_line_1=Each enum has its own separate page with the following sections: 4.24 doclet.Help_enum_line_2=Enum declaration 4.25 doclet.Help_enum_line_3=Enum description
5.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Thu Mar 24 11:20:59 2011 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Sat Mar 26 00:11:34 2011 -0700 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -129,19 +129,11 @@ 5.11 5.12 public Boolean call() { 5.13 if (!used.getAndSet(true)) { 5.14 - beginContext(); 5.15 + initContext(); 5.16 notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>(); 5.17 - try { 5.18 - compilerMain.setFatalErrors(true); 5.19 - result = compilerMain.compile(args, context, fileObjects, processors); 5.20 - } finally { 5.21 - endContext(); 5.22 - } 5.23 - compilerMain = null; 5.24 - args = null; 5.25 - context = null; 5.26 - fileObjects = null; 5.27 - notYetEntered = null; 5.28 + compilerMain.setFatalErrors(true); 5.29 + result = compilerMain.compile(args, context, fileObjects, processors); 5.30 + cleanup(); 5.31 return result == 0; 5.32 } else { 5.33 throw new IllegalStateException("multiple calls to method 'call'"); 5.34 @@ -163,8 +155,11 @@ 5.35 } 5.36 5.37 private void prepareCompiler() throws IOException { 5.38 - if (!used.getAndSet(true)) { 5.39 - beginContext(); 5.40 + if (used.getAndSet(true)) { 5.41 + if (compiler == null) 5.42 + throw new IllegalStateException(); 5.43 + } else { 5.44 + initContext(); 5.45 compilerMain.setOptions(Options.instance(context)); 5.46 compilerMain.filenames = new ListBuffer<File>(); 5.47 List<File> filenames = compilerMain.processArgs(CommandLine.parse(args)); 5.48 @@ -185,13 +180,12 @@ 5.49 } 5.50 } 5.51 5.52 - private void beginContext() { 5.53 + private void initContext() { 5.54 context.put(JavacTaskImpl.class, this); 5.55 if (context.get(TaskListener.class) != null) 5.56 context.put(TaskListener.class, (TaskListener)null); 5.57 if (taskListener != null) 5.58 context.put(TaskListener.class, wrap(taskListener)); 5.59 - tool.beginContext(context); 5.60 //initialize compiler's default locale 5.61 JavacMessages.instance(context).setCurrentLocale(locale); 5.62 } 5.63 @@ -218,8 +212,15 @@ 5.64 }; 5.65 } 5.66 5.67 - private void endContext() { 5.68 - tool.endContext(); 5.69 + void cleanup() { 5.70 + if (compiler != null) 5.71 + compiler.close(); 5.72 + compiler = null; 5.73 + compilerMain = null; 5.74 + args = null; 5.75 + context = null; 5.76 + fileObjects = null; 5.77 + notYetEntered = null; 5.78 } 5.79 5.80 /** 5.81 @@ -446,12 +447,12 @@ 5.82 } 5.83 if (genList.isEmpty()) { 5.84 compiler.reportDeferredDiagnostics(); 5.85 - compiler.log.flush(); 5.86 - endContext(); 5.87 + cleanup(); 5.88 } 5.89 } 5.90 finally { 5.91 - compiler.log.flush(); 5.92 + if (compiler != null) 5.93 + compiler.log.flush(); 5.94 } 5.95 return results; 5.96 }
6.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTool.java Thu Mar 24 11:20:59 2011 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTool.java Sat Mar 26 00:11:34 2011 -0700 6.3 @@ -152,36 +152,6 @@ 6.4 return new JavacFileManager(context, true, charset); 6.5 } 6.6 6.7 - private boolean compilationInProgress = false; 6.8 - 6.9 - /** 6.10 - * Register that a compilation is about to start. 6.11 - */ 6.12 - void beginContext(Context context) { 6.13 - if (compilationInProgress) 6.14 - throw new IllegalStateException("Compilation in progress"); 6.15 - compilationInProgress = true; 6.16 - final JavaFileManager givenFileManager = context.get(JavaFileManager.class); 6.17 - context.put(JavaFileManager.class, (JavaFileManager)null); 6.18 - context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() { 6.19 - public JavaFileManager make(Context c) { 6.20 - if (givenFileManager != null) { 6.21 - c.put(JavaFileManager.class, givenFileManager); 6.22 - return givenFileManager; 6.23 - } else { 6.24 - return new JavacFileManager(c, true, null); 6.25 - } 6.26 - } 6.27 - }); 6.28 - } 6.29 - 6.30 - /** 6.31 - * Register that a compilation is completed. 6.32 - */ 6.33 - void endContext() { 6.34 - compilationInProgress = false; 6.35 - } 6.36 - 6.37 public JavacTask getTask(Writer out, 6.38 JavaFileManager fileManager, 6.39 DiagnosticListener<? super JavaFileObject> diagnosticListener,
7.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java Thu Mar 24 11:20:59 2011 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Sat Mar 26 00:11:34 2011 -0700 7.3 @@ -131,6 +131,12 @@ 7.4 public boolean allowMulticatch() { 7.5 return compareTo(JDK1_7) >= 0; 7.6 } 7.7 + public boolean allowImprovedRethrowAnalysis() { 7.8 + return compareTo(JDK1_7) >= 0; 7.9 + } 7.10 + public boolean allowImprovedCatchAnalysis() { 7.11 + return compareTo(JDK1_7) >= 0; 7.12 + } 7.13 public boolean allowEnums() { 7.14 return compareTo(JDK1_5) >= 0; 7.15 }
8.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Mar 24 11:20:59 2011 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Sat Mar 26 00:11:34 2011 -0700 8.3 @@ -3004,6 +3004,30 @@ 8.4 throw new AssertionError(); 8.5 } 8.6 8.7 + /** 8.8 + * Attribute an env for either a top level tree or class declaration. 8.9 + */ 8.10 + public void attrib(Env<AttrContext> env) { 8.11 + if (env.tree.getTag() == JCTree.TOPLEVEL) 8.12 + attribTopLevel(env); 8.13 + else 8.14 + attribClass(env.tree.pos(), env.enclClass.sym); 8.15 + } 8.16 + 8.17 + /** 8.18 + * Attribute a top level tree. These trees are encountered when the 8.19 + * package declaration has annotations. 8.20 + */ 8.21 + public void attribTopLevel(Env<AttrContext> env) { 8.22 + JCCompilationUnit toplevel = env.toplevel; 8.23 + try { 8.24 + annotate.flush(); 8.25 + chk.validateAnnotations(toplevel.packageAnnotations, toplevel.packge); 8.26 + } catch (CompletionFailure ex) { 8.27 + chk.completionError(toplevel.pos(), ex); 8.28 + } 8.29 + } 8.30 + 8.31 /** Main method: attribute class definition associated with given class symbol. 8.32 * reporting completion failures at the given position. 8.33 * @param pos The source position at which completion errors are to be
9.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Thu Mar 24 11:20:59 2011 -0700 9.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Sat Mar 26 00:11:34 2011 -0700 9.3 @@ -190,7 +190,8 @@ 9.4 private final Resolve rs; 9.5 private Env<AttrContext> attrEnv; 9.6 private Lint lint; 9.7 - private final boolean allowRethrowAnalysis; 9.8 + private final boolean allowImprovedRethrowAnalysis; 9.9 + private final boolean allowImprovedCatchAnalysis; 9.10 9.11 public static Flow instance(Context context) { 9.12 Flow instance = context.get(flowKey); 9.13 @@ -209,7 +210,8 @@ 9.14 lint = Lint.instance(context); 9.15 rs = Resolve.instance(context); 9.16 Source source = Source.instance(context); 9.17 - allowRethrowAnalysis = source.allowMulticatch(); 9.18 + allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis(); 9.19 + allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis(); 9.20 } 9.21 9.22 /** A flag that indicates whether the last statement could 9.23 @@ -1046,7 +1048,9 @@ 9.24 } 9.25 } 9.26 scanStat(tree.body); 9.27 - List<Type> thrownInTry = thrown; 9.28 + List<Type> thrownInTry = allowImprovedCatchAnalysis ? 9.29 + chk.union(thrown, List.of(syms.runtimeExceptionType, syms.errorType)) : 9.30 + thrown; 9.31 thrown = thrownPrev; 9.32 caught = caughtPrev; 9.33 boolean aliveEnd = alive; 9.34 @@ -1081,16 +1085,7 @@ 9.35 ctypes = ctypes.append(exc); 9.36 if (types.isSameType(exc, syms.objectType)) 9.37 continue; 9.38 - if (chk.subset(exc, caughtInTry)) { 9.39 - log.error(l.head.pos(), 9.40 - "except.already.caught", exc); 9.41 - } else if (!chk.isUnchecked(l.head.pos(), exc) && 9.42 - exc.tsym != syms.throwableType.tsym && 9.43 - exc.tsym != syms.exceptionType.tsym && 9.44 - !chk.intersects(exc, thrownInTry)) { 9.45 - log.error(l.head.pos(), 9.46 - "except.never.thrown.in.try", exc); 9.47 - } 9.48 + checkCaughtType(l.head.pos(), exc, thrownInTry, caughtInTry); 9.49 caughtInTry = chk.incl(exc, caughtInTry); 9.50 } 9.51 } 9.52 @@ -1154,6 +1149,29 @@ 9.53 uninitsTry.andSet(uninitsTryPrev).andSet(uninits); 9.54 } 9.55 9.56 + void checkCaughtType(DiagnosticPosition pos, Type exc, List<Type> thrownInTry, List<Type> caughtInTry) { 9.57 + if (chk.subset(exc, caughtInTry)) { 9.58 + log.error(pos, "except.already.caught", exc); 9.59 + } else if (!chk.isUnchecked(pos, exc) && 9.60 + exc.tsym != syms.throwableType.tsym && 9.61 + exc.tsym != syms.exceptionType.tsym && 9.62 + !chk.intersects(exc, thrownInTry)) { 9.63 + log.error(pos, "except.never.thrown.in.try", exc); 9.64 + } else if (allowImprovedCatchAnalysis) { 9.65 + List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry); 9.66 + // 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an 9.67 + // unchecked exception, the result list would not be empty, as the augmented 9.68 + // thrown set includes { RuntimeException, Error }; if 'exc' was a checked 9.69 + // exception, that would have been covered in the branch above 9.70 + if (chk.diff(catchableThrownTypes, caughtInTry).isEmpty()) { 9.71 + String key = catchableThrownTypes.length() == 1 ? 9.72 + "unreachable.catch" : 9.73 + "unreachable.catch.1"; 9.74 + log.warning(pos, key, catchableThrownTypes); 9.75 + } 9.76 + } 9.77 + } 9.78 + 9.79 public void visitConditional(JCConditional tree) { 9.80 scanCond(tree.cond); 9.81 Bits initsBeforeElse = initsWhenFalse; 9.82 @@ -1238,7 +1256,7 @@ 9.83 sym.kind == VAR && 9.84 (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 && 9.85 preciseRethrowTypes.get(sym) != null && 9.86 - allowRethrowAnalysis) { 9.87 + allowImprovedRethrowAnalysis) { 9.88 for (Type t : preciseRethrowTypes.get(sym)) { 9.89 markThrown(tree, t); 9.90 }
10.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Thu Mar 24 11:20:59 2011 -0700 10.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Sat Mar 26 00:11:34 2011 -0700 10.3 @@ -89,7 +89,7 @@ 10.4 10.5 private FSInfo fsInfo; 10.6 10.7 - private boolean useZipFileIndex; 10.8 + private boolean contextUseOptimizedZip; 10.9 private ZipFileIndexCache zipFileIndexCache; 10.10 10.11 private final File uninited = new File("U N I N I T E D"); 10.12 @@ -164,8 +164,8 @@ 10.13 10.14 fsInfo = FSInfo.instance(context); 10.15 10.16 - useZipFileIndex = options.isSet("useOptimizedZip"); 10.17 - if (useZipFileIndex) 10.18 + contextUseOptimizedZip = options.getBoolean("useOptimizedZip", true); 10.19 + if (contextUseOptimizedZip) 10.20 zipFileIndexCache = ZipFileIndexCache.getSharedInstance(); 10.21 10.22 mmappedIO = options.isSet("mmappedIO"); 10.23 @@ -471,9 +471,27 @@ 10.24 private static final RelativeDirectory symbolFilePrefix 10.25 = new RelativeDirectory("META-INF/sym/rt.jar/"); 10.26 10.27 + /* 10.28 + * This method looks for a ZipFormatException and takes appropriate 10.29 + * evasive action. If there is a failure in the fast mode then we 10.30 + * fail over to the platform zip, and allow it to deal with a potentially 10.31 + * non compliant zip file. 10.32 + */ 10.33 + protected Archive openArchive(File zipFilename) throws IOException { 10.34 + try { 10.35 + return openArchive(zipFilename, contextUseOptimizedZip); 10.36 + } catch (IOException ioe) { 10.37 + if (ioe instanceof ZipFileIndex.ZipFormatException) { 10.38 + return openArchive(zipFilename, false); 10.39 + } else { 10.40 + throw ioe; 10.41 + } 10.42 + } 10.43 + } 10.44 + 10.45 /** Open a new zip file directory, and cache it. 10.46 */ 10.47 - protected Archive openArchive(File zipFileName) throws IOException { 10.48 + private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException { 10.49 File origZipFileName = zipFileName; 10.50 if (!ignoreSymbolFile && paths.isDefaultBootClassPathRtJar(zipFileName)) { 10.51 File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 10.52 @@ -495,7 +513,7 @@ 10.53 boolean usePreindexedCache = false; 10.54 String preindexCacheLocation = null; 10.55 10.56 - if (!useZipFileIndex) { 10.57 + if (!useOptimizedZip) { 10.58 zdir = new ZipFile(zipFileName); 10.59 } else { 10.60 usePreindexedCache = options.isSet("usezipindex"); 10.61 @@ -524,23 +542,22 @@ 10.62 } 10.63 10.64 if (origZipFileName == zipFileName) { 10.65 - if (!useZipFileIndex) { 10.66 + if (!useOptimizedZip) { 10.67 archive = new ZipArchive(this, zdir); 10.68 } else { 10.69 archive = new ZipFileIndexArchive(this, 10.70 - zipFileIndexCache.getZipFileIndex(zipFileName, 10.71 + zipFileIndexCache.getZipFileIndex(zipFileName, 10.72 null, 10.73 usePreindexedCache, 10.74 preindexCacheLocation, 10.75 options.isSet("writezipindexfiles"))); 10.76 } 10.77 } else { 10.78 - if (!useZipFileIndex) { 10.79 + if (!useOptimizedZip) { 10.80 archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); 10.81 - } 10.82 - else { 10.83 + } else { 10.84 archive = new ZipFileIndexArchive(this, 10.85 - zipFileIndexCache.getZipFileIndex(zipFileName, 10.86 + zipFileIndexCache.getZipFileIndex(zipFileName, 10.87 symbolFilePrefix, 10.88 usePreindexedCache, 10.89 preindexCacheLocation, 10.90 @@ -549,6 +566,8 @@ 10.91 } 10.92 } catch (FileNotFoundException ex) { 10.93 archive = new MissingArchive(zipFileName); 10.94 + } catch (ZipFileIndex.ZipFormatException zfe) { 10.95 + throw zfe; 10.96 } catch (IOException ex) { 10.97 if (zipFileName.exists()) 10.98 log.error("error.reading.file", zipFileName, getMessage(ex));
11.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Thu Mar 24 11:20:59 2011 -0700 11.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java Sat Mar 26 00:11:34 2011 -0700 11.3 @@ -492,8 +492,30 @@ 11.4 public ZipDirectory(RandomAccessFile zipRandomFile, long start, long end, ZipFileIndex index) throws IOException { 11.5 this.zipRandomFile = zipRandomFile; 11.6 this.zipFileIndex = index; 11.7 + hasValidHeader(); 11.8 + findCENRecord(start, end); 11.9 + } 11.10 11.11 - findCENRecord(start, end); 11.12 + /* 11.13 + * the zip entry signature should be at offset 0, otherwise allow the 11.14 + * calling logic to take evasive action by throwing ZipFormatException. 11.15 + */ 11.16 + private boolean hasValidHeader() throws IOException { 11.17 + final long pos = zipRandomFile.getFilePointer(); 11.18 + try { 11.19 + if (zipRandomFile.read() == 'P') { 11.20 + if (zipRandomFile.read() == 'K') { 11.21 + if (zipRandomFile.read() == 0x03) { 11.22 + if (zipRandomFile.read() == 0x04) { 11.23 + return true; 11.24 + } 11.25 + } 11.26 + } 11.27 + } 11.28 + } finally { 11.29 + zipRandomFile.seek(pos); 11.30 + } 11.31 + throw new ZipFormatException("invalid zip magic"); 11.32 } 11.33 11.34 /* 11.35 @@ -529,7 +551,13 @@ 11.36 zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12) + 2]; 11.37 zipDir[0] = endbuf[i + 10]; 11.38 zipDir[1] = endbuf[i + 11]; 11.39 - zipRandomFile.seek(start + get4ByteLittleEndian(endbuf, i + 16)); 11.40 + int sz = get4ByteLittleEndian(endbuf, i + 16); 11.41 + // a negative offset or the entries field indicates a 11.42 + // potential zip64 archive 11.43 + if (sz < 0 || get2ByteLittleEndian(zipDir, 0) == 0xffff) { 11.44 + throw new ZipFormatException("detected a zip64 archive"); 11.45 + } 11.46 + zipRandomFile.seek(start + sz); 11.47 zipRandomFile.readFully(zipDir, 2, zipDir.length - 2); 11.48 return; 11.49 } else { 11.50 @@ -1127,4 +1155,18 @@ 11.51 } 11.52 } 11.53 11.54 + /* 11.55 + * Exception primarily used to implement a failover, used exclusively here. 11.56 + */ 11.57 + 11.58 + static final class ZipFormatException extends IOException { 11.59 + private static final long serialVersionUID = 8000196834066748623L; 11.60 + protected ZipFormatException(String message) { 11.61 + super(message); 11.62 + } 11.63 + 11.64 + protected ZipFormatException(String message, Throwable cause) { 11.65 + super(message, cause); 11.66 + } 11.67 + } 11.68 }
12.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu Mar 24 11:20:59 2011 -0700 12.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Sat Mar 26 00:11:34 2011 -0700 12.3 @@ -638,6 +638,19 @@ 12.4 } 12.5 } 12.6 12.7 + /** Resolve an identifier which may be the binary name of a class or 12.8 + * the Java name of a class or package. 12.9 + * @param name The name to resolve 12.10 + */ 12.11 + public Symbol resolveBinaryNameOrIdent(String name) { 12.12 + try { 12.13 + Name flatname = names.fromString(name.replace("/", ".")); 12.14 + return reader.loadClass(flatname); 12.15 + } catch (CompletionFailure ignore) { 12.16 + return resolveIdent(name); 12.17 + } 12.18 + } 12.19 + 12.20 /** Resolve an identifier. 12.21 * @param name The identifier to resolve 12.22 */ 12.23 @@ -1058,7 +1071,7 @@ 12.24 } else { 12.25 boolean errors = false; 12.26 for (String nameStr : classnames) { 12.27 - Symbol sym = resolveIdent(nameStr); 12.28 + Symbol sym = resolveBinaryNameOrIdent(nameStr); 12.29 if (sym == null || (sym.kind == Kinds.PCK && !processPcks)) { 12.30 log.error("proc.cant.find.class", nameStr); 12.31 errors = true; 12.32 @@ -1166,7 +1179,7 @@ 12.33 env.enclClass.sym.sourcefile : 12.34 env.toplevel.sourcefile); 12.35 try { 12.36 - attr.attribClass(env.tree.pos(), env.enclClass.sym); 12.37 + attr.attrib(env); 12.38 if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) { 12.39 //if in fail-over mode, ensure that AST expression nodes 12.40 //are correctly initialized (e.g. they have a type/symbol)
13.1 --- a/src/share/classes/com/sun/tools/javac/model/JavacTypes.java Thu Mar 24 11:20:59 2011 -0700 13.2 +++ b/src/share/classes/com/sun/tools/javac/model/JavacTypes.java Sat Mar 26 00:11:34 2011 -0700 13.3 @@ -1,5 +1,5 @@ 13.4 /* 13.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 13.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.8 * 13.9 * This code is free software; you can redistribute it and/or modify it 13.10 @@ -73,9 +73,14 @@ 13.11 13.12 public Element asElement(TypeMirror t) { 13.13 Type type = cast(Type.class, t); 13.14 - if (type.tag != TypeTags.CLASS && type.tag != TypeTags.TYPEVAR) 13.15 - return null; 13.16 - return type.asElement(); 13.17 + switch (type.tag) { 13.18 + case TypeTags.CLASS: 13.19 + case TypeTags.ERROR: 13.20 + case TypeTags.TYPEVAR: 13.21 + return type.asElement(); 13.22 + default: 13.23 + return null; 13.24 + } 13.25 } 13.26 13.27 public boolean isSameType(TypeMirror t1, TypeMirror t2) {
14.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Mar 24 11:20:59 2011 -0700 14.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Sat Mar 26 00:11:34 2011 -0700 14.3 @@ -820,13 +820,17 @@ 14.4 /** The set of package-info files to be processed this round. */ 14.5 List<PackageSymbol> packageInfoFiles; 14.6 14.7 + /** The number of Messager errors generated in this round. */ 14.8 + int nMessagerErrors; 14.9 + 14.10 /** Create a round (common code). */ 14.11 - private Round(Context context, int number, int priorWarnings) { 14.12 + private Round(Context context, int number, int priorErrors, int priorWarnings) { 14.13 this.context = context; 14.14 this.number = number; 14.15 14.16 compiler = JavaCompiler.instance(context); 14.17 log = Log.instance(context); 14.18 + log.nerrors = priorErrors; 14.19 log.nwarnings += priorWarnings; 14.20 log.deferDiagnostics = true; 14.21 14.22 @@ -840,7 +844,7 @@ 14.23 14.24 /** Create the first round. */ 14.25 Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols) { 14.26 - this(context, 1, 0); 14.27 + this(context, 1, 0, 0); 14.28 this.roots = roots; 14.29 genClassFiles = new HashMap<String,JavaFileObject>(); 14.30 14.31 @@ -860,7 +864,10 @@ 14.32 /** Create a new round. */ 14.33 private Round(Round prev, 14.34 Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) { 14.35 - this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings); 14.36 + this(prev.nextContext(), 14.37 + prev.number+1, 14.38 + prev.nMessagerErrors, 14.39 + prev.compiler.log.nwarnings); 14.40 this.genClassFiles = prev.genClassFiles; 14.41 14.42 List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles); 14.43 @@ -1014,6 +1021,8 @@ 14.44 if (taskListener != null) 14.45 taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND)); 14.46 } 14.47 + 14.48 + nMessagerErrors = messager.errorCount(); 14.49 } 14.50 14.51 void showDiagnostics(boolean showAll) {
15.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Mar 24 11:20:59 2011 -0700 15.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Sat Mar 26 00:11:34 2011 -0700 15.3 @@ -1102,6 +1102,16 @@ 15.4 cast to {0} for a varargs call\n\ 15.5 cast to {1} for a non-varargs call and to suppress this warning 15.6 15.7 +# 0: list of type 15.8 +compiler.warn.unreachable.catch=\ 15.9 + unreachable catch clause\n\ 15.10 + thrown type {0} has already been caught 15.11 + 15.12 +# 0: list of type 15.13 +compiler.warn.unreachable.catch.1=\ 15.14 + unreachable catch clause\n\ 15.15 + thrown types {0} have already been caught 15.16 + 15.17 # 0: symbol 15.18 compiler.warn.long.SVUID=\ 15.19 serialVersionUID must be of type long in class {0}
16.1 --- a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Thu Mar 24 11:20:59 2011 -0700 16.2 +++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java Sat Mar 26 00:11:34 2011 -0700 16.3 @@ -1,5 +1,5 @@ 16.4 /* 16.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 16.6 + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 16.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.8 * 16.9 * This code is free software; you can redistribute it and/or modify it 16.10 @@ -26,6 +26,7 @@ 16.11 package com.sun.tools.javac.util; 16.12 16.13 import java.util.Collection; 16.14 +import java.util.EnumMap; 16.15 import java.util.EnumSet; 16.16 import java.util.HashMap; 16.17 import java.util.Locale; 16.18 @@ -226,17 +227,14 @@ 16.19 DiagnosticPart.SOURCE)); 16.20 initFormat(); 16.21 initIndentation(); 16.22 + if (options.isSet("oldDiags")) 16.23 + initOldFormat(); 16.24 String fmt = options.get("diagsFormat"); 16.25 if (fmt != null) { 16.26 - String[] formats = fmt.split("\\|"); 16.27 - switch (formats.length) { 16.28 - case 3: 16.29 - setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]); 16.30 - case 2: 16.31 - setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]); 16.32 - default: 16.33 - setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]); 16.34 - } 16.35 + if (fmt.equals("OLD")) 16.36 + initOldFormat(); 16.37 + else 16.38 + initFormats(fmt); 16.39 } 16.40 String srcPos = null; 16.41 if ((((srcPos = options.get("sourcePosition")) != null)) && 16.42 @@ -280,14 +278,35 @@ 16.43 initFormat(); 16.44 initIndentation(); 16.45 } 16.46 - //where 16.47 + 16.48 private void initFormat() { 16.49 - availableFormats = new HashMap<BasicFormatKind, String>(); 16.50 - setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, "%f:%l:%_%t%L%m"); 16.51 - setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, "%p%L%m"); 16.52 - setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, "%f:%_%t%L%m"); 16.53 + initFormats("%f:%l:%_%p%L%m", "%p%L%m", "%f:%_%p%L%m"); 16.54 } 16.55 - //where 16.56 + 16.57 + private void initOldFormat() { 16.58 + initFormats("%f:%l:%_%t%L%m", "%p%L%m", "%f:%_%t%L%m"); 16.59 + } 16.60 + 16.61 + private void initFormats(String pos, String nopos, String clazz) { 16.62 + availableFormats = new EnumMap<BasicFormatKind, String>(BasicFormatKind.class); 16.63 + setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, pos); 16.64 + setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, nopos); 16.65 + setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, clazz); 16.66 + } 16.67 + 16.68 + @SuppressWarnings("fallthrough") 16.69 + private void initFormats(String fmt) { 16.70 + String[] formats = fmt.split("\\|"); 16.71 + switch (formats.length) { 16.72 + case 3: 16.73 + setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]); 16.74 + case 2: 16.75 + setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]); 16.76 + default: 16.77 + setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]); 16.78 + } 16.79 + } 16.80 + 16.81 private void initIndentation() { 16.82 indentationLevels = new HashMap<DiagnosticPart, Integer>(); 16.83 setIndentation(DiagnosticPart.SUMMARY, 0);
17.1 --- a/src/share/classes/com/sun/tools/javac/util/Options.java Thu Mar 24 11:20:59 2011 -0700 17.2 +++ b/src/share/classes/com/sun/tools/javac/util/Options.java Sat Mar 26 00:11:34 2011 -0700 17.3 @@ -76,6 +76,22 @@ 17.4 } 17.5 17.6 /** 17.7 + * Get the boolean value for an option, patterned after Boolean.getBoolean, 17.8 + * essentially will return true, iff the value exists and is set to "true". 17.9 + */ 17.10 + public boolean getBoolean(String name) { 17.11 + return getBoolean(name, false); 17.12 + } 17.13 + 17.14 + /** 17.15 + * Get the boolean with a default value if the option is not set. 17.16 + */ 17.17 + public boolean getBoolean(String name, boolean defaultValue) { 17.18 + String value = get(name); 17.19 + return (value == null) ? defaultValue : Boolean.parseBoolean(value); 17.20 + } 17.21 + 17.22 + /** 17.23 * Check if the value for an undocumented option has been set. 17.24 */ 17.25 public boolean isSet(String name) {
18.1 --- a/src/share/classes/javax/lang/model/element/Element.java Thu Mar 24 11:20:59 2011 -0700 18.2 +++ b/src/share/classes/javax/lang/model/element/Element.java Sat Mar 26 00:11:34 2011 -0700 18.3 @@ -197,11 +197,12 @@ 18.4 * <li> If this is a {@linkplain 18.5 * PackageElement#getEnclosingElement package}, {@code null} is 18.6 * returned. 18.7 - 18.8 + * 18.9 * <li> If this is a {@linkplain 18.10 * TypeParameterElement#getEnclosingElement type parameter}, 18.11 - * {@code null} is returned. 18.12 - 18.13 + * {@linkplain TypeParameterElement#getGenericElement the 18.14 + * generic element} of the type parameter is returned. 18.15 + * 18.16 * </ul> 18.17 * 18.18 * @return the enclosing element, or {@code null} if there is none
19.1 --- a/src/share/classes/javax/lang/model/element/TypeParameterElement.java Thu Mar 24 11:20:59 2011 -0700 19.2 +++ b/src/share/classes/javax/lang/model/element/TypeParameterElement.java Sat Mar 26 00:11:34 2011 -0700 19.3 @@ -64,9 +64,9 @@ 19.4 List<? extends TypeMirror> getBounds(); 19.5 19.6 /** 19.7 - * Returns {@code null}. 19.8 + * Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter. 19.9 * 19.10 - * @return {@code null} 19.11 + * @return the generic element of this type parameter 19.12 */ 19.13 @Override 19.14 Element getEnclosingElement();
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/com/sun/javadoc/testUseOption/C.java Sat Mar 26 00:11:34 2011 -0700 20.3 @@ -0,0 +1,41 @@ 20.4 +/* 20.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.7 + * 20.8 + * This code is free software; you can redistribute it and/or modify it 20.9 + * under the terms of the GNU General Public License version 2 only, as 20.10 + * published by the Free Software Foundation. 20.11 + * 20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20.15 + * version 2 for more details (a copy is included in the LICENSE file that 20.16 + * accompanied this code). 20.17 + * 20.18 + * You should have received a copy of the GNU General Public License version 20.19 + * 2 along with this work; if not, write to the Free Software Foundation, 20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20.21 + * 20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20.23 + * or visit www.oracle.com if you need additional information or have any 20.24 + * questions. 20.25 + */ 20.26 + 20.27 +/** 20.28 + * Class in an unnamed package. 20.29 + */ 20.30 + 20.31 +public class C { 20.32 + 20.33 + /** 20.34 + * Field in C. 20.35 + */ 20.36 + public UsedInC fieldInC; 20.37 + 20.38 + /** 20.39 + * Method in C. 20.40 + */ 20.41 + public UsedInC methodInC(UsedInC p) { 20.42 + return p; 20.43 + } 20.44 +}
21.1 --- a/test/com/sun/javadoc/testUseOption/TestUseOption.java Thu Mar 24 11:20:59 2011 -0700 21.2 +++ b/test/com/sun/javadoc/testUseOption/TestUseOption.java Sat Mar 26 00:11:34 2011 -0700 21.3 @@ -1,5 +1,5 @@ 21.4 /* 21.5 - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. 21.6 + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.8 * 21.9 * This code is free software; you can redistribute it and/or modify it 21.10 @@ -23,7 +23,7 @@ 21.11 21.12 /* 21.13 * @test 21.14 - * @bug 4496290 4985072 21.15 + * @bug 4496290 4985072 7006178 21.16 * @summary A simple test to determine if -use works. 21.17 * @author jamieh 21.18 * @library ../lib/ 21.19 @@ -34,7 +34,7 @@ 21.20 21.21 public class TestUseOption extends JavadocTester { 21.22 21.23 - private static final String BUG_ID = "4496290-4985072"; 21.24 + private static final String BUG_ID = "4496290-4985072-7006178"; 21.25 21.26 //Input for string search tests. 21.27 private static final String[] TEST2 = { 21.28 @@ -54,6 +54,16 @@ 21.29 "Method in C8.", 21.30 }; 21.31 21.32 + private static final String[][] TEST3 = { 21.33 + {BUG_ID + "-3" + FS + "class-use" + FS + "UsedInC.html", "Uses of <a href=" + 21.34 + "\"../UsedInC.html\" title=\"class in <Unnamed>\">" + 21.35 + "UsedInC</a> in <a href=\"../package-summary.html\"><Unnamed></a>" 21.36 + }, 21.37 + {BUG_ID + "-3" + FS + "package-use.html", "<td class=\"colOne\">" + 21.38 + "<a href=\"class-use/UsedInC.html#<Unnamed>\">UsedInC</a> </td>" 21.39 + } 21.40 + }; 21.41 + 21.42 private static final String[] ARGS = new String[] { 21.43 "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2" 21.44 }; 21.45 @@ -62,6 +72,10 @@ 21.46 "-d", BUG_ID+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2" 21.47 }; 21.48 21.49 + private static final String[] ARGS3 = new String[] { 21.50 + "-d", BUG_ID + "-3", "-sourcepath", SRC_DIR, "-use", SRC_DIR + FS + "C.java", SRC_DIR + FS + "UsedInC.java" 21.51 + }; 21.52 + 21.53 /** 21.54 * The entry point of the test. 21.55 * @param args the array of command line arguments. 21.56 @@ -93,6 +107,8 @@ 21.57 prevIndex = currentIndex; 21.58 } 21.59 tester.printSummary(); 21.60 + run(tester, ARGS3, TEST3, NO_TEST); 21.61 + tester.printSummary(); 21.62 } 21.63 21.64 /**
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/com/sun/javadoc/testUseOption/UsedInC.java Sat Mar 26 00:11:34 2011 -0700 22.3 @@ -0,0 +1,26 @@ 22.4 +/* 22.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 + * 22.8 + * This code is free software; you can redistribute it and/or modify it 22.9 + * under the terms of the GNU General Public License version 2 only, as 22.10 + * published by the Free Software Foundation. 22.11 + * 22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.15 + * version 2 for more details (a copy is included in the LICENSE file that 22.16 + * accompanied this code). 22.17 + * 22.18 + * You should have received a copy of the GNU General Public License version 22.19 + * 2 along with this work; if not, write to the Free Software Foundation, 22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.21 + * 22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22.23 + * or visit www.oracle.com if you need additional information or have any 22.24 + * questions. 22.25 + */ 22.26 + 22.27 +public class UsedInC 22.28 +{ 22.29 +}
23.1 --- a/test/tools/apt/Compile/golden.txt Thu Mar 24 11:20:59 2011 -0700 23.2 +++ b/test/tools/apt/Compile/golden.txt Sat Mar 26 00:11:34 2011 -0700 23.3 @@ -1,6 +1,6 @@ 23.4 error: It's a mad, mad, mad, mad world 23.5 error: Something wicked this way comes 23.6 -HelloWorld.java:2: Boring class name 23.7 +HelloWorld.java:2: error: Boring class name 23.8 public class HelloWorld { 23.9 ^ 23.10 3 errors
24.1 --- a/test/tools/javac/4846262/Test.out Thu Mar 24 11:20:59 2011 -0700 24.2 +++ b/test/tools/javac/4846262/Test.out Sat Mar 26 00:11:34 2011 -0700 24.3 @@ -1,7 +1,7 @@ 24.4 -Test.java:4: not a statement 24.5 +Test.java:4: error: not a statement 24.6 abcdefg 24.7 ^ 24.8 -Test.java:4: ';' expected 24.9 +Test.java:4: error: ';' expected 24.10 abcdefg 24.11 ^ 24.12 2 errors
25.1 --- a/test/tools/javac/6508981/TestInferBinaryName.java Thu Mar 24 11:20:59 2011 -0700 25.2 +++ b/test/tools/javac/6508981/TestInferBinaryName.java Sat Mar 26 00:11:34 2011 -0700 25.3 @@ -139,9 +139,8 @@ 25.4 throws IOException { 25.5 Context ctx = new Context(); 25.6 Options options = Options.instance(ctx); 25.7 - // uugh, ugly back door, should be cleaned up, someday 25.8 - if (zipFileIndexKind == USE_ZIP_FILE_INDEX) 25.9 - options.put("useOptimizedZip", "true"); 25.10 + options.put("useOptimizedZip", 25.11 + Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX)); 25.12 25.13 if (symFileKind == IGNORE_SYMBOL_FILE) 25.14 options.put("ignore.symbol.file", "true");
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/test/tools/javac/6558548/T6558548.java Sat Mar 26 00:11:34 2011 -0700 26.3 @@ -0,0 +1,300 @@ 26.4 +/* 26.5 + * @test /nodynamiccopyright/ 26.6 + * @bug 6558548 26.7 + * @summary The compiler needs to be aligned with clarified specification of throws 26.8 + * @compile/fail/ref=T6558548_latest.out -XDrawDiagnostics T6558548.java 26.9 + * @compile/fail/ref=T6558548_6.out -source 6 -XDrawDiagnostics T6558548.java 26.10 + */ 26.11 + 26.12 +class T6558548 { 26.13 + 26.14 + void nothing() {} 26.15 + void checked() throws InterruptedException {} 26.16 + void runtime() throws IllegalArgumentException {} 26.17 + 26.18 + void m1() { 26.19 + try { 26.20 + throw new java.io.FileNotFoundException(); 26.21 + } 26.22 + catch(java.io.FileNotFoundException exc) { } 26.23 + catch(java.io.IOException exc) { } // 6: ok; latest: unreachable 26.24 + } 26.25 + 26.26 + void m1a() { 26.27 + try { 26.28 + throw new java.io.IOException(); 26.29 + } 26.30 + catch(java.io.FileNotFoundException exc) { } 26.31 + catch(java.io.IOException exc) { } //ok 26.32 + } 26.33 + 26.34 + void m2() { 26.35 + try { 26.36 + nothing(); 26.37 + } 26.38 + catch(Exception exc) { } // ok 26.39 + } 26.40 + 26.41 + void m3() { 26.42 + try { 26.43 + checked(); 26.44 + } 26.45 + catch(Exception exc) { } //ok 26.46 + } 26.47 + 26.48 + void m4() { 26.49 + try { 26.50 + runtime(); 26.51 + } 26.52 + catch(Exception exc) { } //ok 26.53 + } 26.54 + 26.55 + void m5() { 26.56 + try { 26.57 + nothing(); 26.58 + } 26.59 + catch(Throwable exc) { } //ok 26.60 + } 26.61 + 26.62 + void m6() { 26.63 + try { 26.64 + checked(); 26.65 + } 26.66 + catch(Throwable exc) { } //ok 26.67 + } 26.68 + 26.69 + void m7() { 26.70 + try { 26.71 + runtime(); 26.72 + } 26.73 + catch(Throwable exc) { } //ok 26.74 + } 26.75 + 26.76 + void m9() { 26.77 + try { 26.78 + checked(); 26.79 + } 26.80 + catch(Error exc) { } 26.81 + catch(Throwable exc) { } //ok 26.82 + } 26.83 + 26.84 + void m10() { 26.85 + try { 26.86 + runtime(); 26.87 + } 26.88 + catch(Error exc) { } 26.89 + catch(Throwable exc) { } //ok 26.90 + } 26.91 + 26.92 + void m11() { 26.93 + try { 26.94 + nothing(); 26.95 + } 26.96 + catch(Error exc) { } 26.97 + catch(Throwable exc) { } //ok 26.98 + } 26.99 + 26.100 + void m12() { 26.101 + try { 26.102 + checked(); 26.103 + } 26.104 + catch(RuntimeException exc) { } 26.105 + catch(Throwable exc) { } // ok 26.106 + } 26.107 + 26.108 + void m13() { 26.109 + try { 26.110 + runtime(); 26.111 + } 26.112 + catch(RuntimeException exc) { } 26.113 + catch(Throwable exc) { } // ok 26.114 + } 26.115 + 26.116 + void m14() { 26.117 + try { 26.118 + nothing(); 26.119 + } 26.120 + catch(RuntimeException exc) { } 26.121 + catch(Throwable exc) { } // ok 26.122 + } 26.123 + 26.124 + void m15() { 26.125 + try { 26.126 + checked(); 26.127 + } 26.128 + catch(RuntimeException exc) { } 26.129 + catch(Exception exc) { } //ok 26.130 + } 26.131 + 26.132 + void m16() { 26.133 + try { 26.134 + runtime(); 26.135 + } 26.136 + catch(RuntimeException exc) { } 26.137 + catch(Exception exc) { } //6: ok; latest: unreachable 26.138 + } 26.139 + 26.140 + void m17() { 26.141 + try { 26.142 + nothing(); 26.143 + } 26.144 + catch(RuntimeException exc) { } 26.145 + catch(Exception exc) { } //6: ok; latest: unreachable 26.146 + } 26.147 + 26.148 + void m18() { 26.149 + try { 26.150 + checked(); 26.151 + } 26.152 + catch(RuntimeException exc) { } 26.153 + catch(InterruptedException exc) { } 26.154 + catch(Exception exc) { } //6: ok; latest: unreachable 26.155 + } 26.156 + 26.157 + void m19() { 26.158 + try { 26.159 + runtime(); 26.160 + } 26.161 + catch(RuntimeException exc) { } 26.162 + catch(InterruptedException exc) { } //never thrown in try 26.163 + catch(Exception exc) { } //6: ok; latest: unreachable 26.164 + } 26.165 + 26.166 + void m20() { 26.167 + try { 26.168 + nothing(); 26.169 + } 26.170 + catch(RuntimeException exc) { } 26.171 + catch(InterruptedException exc) { } //never thrown in try 26.172 + catch(Exception exc) { } //6: ok; latest: unreachable 26.173 + } 26.174 + 26.175 + void m21() { 26.176 + try { 26.177 + checked(); 26.178 + } 26.179 + catch(RuntimeException exc) { } 26.180 + catch(Exception exc) { } // ok 26.181 + } 26.182 + 26.183 + void m22() { 26.184 + try { 26.185 + runtime(); 26.186 + } 26.187 + catch(RuntimeException exc) { } 26.188 + catch(Exception exc) { } // 6: ok; latest: unreachable 26.189 + } 26.190 + 26.191 + void m23() { 26.192 + try { 26.193 + nothing(); 26.194 + } 26.195 + catch(RuntimeException exc) { } 26.196 + catch(Exception exc) { } // 6: ok; latest: unreachable 26.197 + } 26.198 + 26.199 + void m24() { 26.200 + try { 26.201 + checked(); 26.202 + } 26.203 + catch(RuntimeException exc) { } 26.204 + catch(Error exc) { } 26.205 + catch(Throwable exc) { } //ok 26.206 + } 26.207 + 26.208 + void m25() { 26.209 + try { 26.210 + runtime(); 26.211 + } 26.212 + catch(RuntimeException exc) { } 26.213 + catch(Error exc) { } 26.214 + catch(Throwable exc) { } //6: ok; latest: unreachable 26.215 + } 26.216 + 26.217 + void m26() { 26.218 + try { 26.219 + nothing(); 26.220 + } 26.221 + catch(RuntimeException exc) { } 26.222 + catch(Error exc) { } 26.223 + catch(Throwable exc) { } //6: ok; latest: unreachable 26.224 + } 26.225 + 26.226 + void m27() { 26.227 + try { 26.228 + checked(); 26.229 + } 26.230 + catch(RuntimeException exc) { } 26.231 + catch(Error exc) { } 26.232 + catch(InterruptedException exc) { } 26.233 + catch(Throwable exc) { } //6: ok; latest: unreachable 26.234 + } 26.235 + 26.236 + void m28() { 26.237 + try { 26.238 + runtime(); 26.239 + } 26.240 + catch(RuntimeException exc) { } 26.241 + catch(Error exc) { } 26.242 + catch(InterruptedException exc) { } //never thrown in try 26.243 + catch(Throwable exc) { } //6: ok; latest: unreachable 26.244 + } 26.245 + 26.246 + void m29() { 26.247 + try { 26.248 + nothing(); 26.249 + } 26.250 + catch(RuntimeException exc) { } 26.251 + catch(Error exc) { } 26.252 + catch(InterruptedException exc) { } //never thrown in try 26.253 + catch(Throwable exc) { } //6: ok; latest: unreachable 26.254 + } 26.255 + 26.256 + void m30() { 26.257 + try { 26.258 + checked(); 26.259 + } 26.260 + catch(RuntimeException exc) { } 26.261 + catch(Error exc) { } 26.262 + catch(Throwable exc) { } //ok 26.263 + } 26.264 + 26.265 + void m31() { 26.266 + try { 26.267 + runtime(); 26.268 + } 26.269 + catch(RuntimeException exc) { } 26.270 + catch(Error exc) { } 26.271 + catch(Throwable exc) { } //6: ok; latest: unreachable 26.272 + } 26.273 + 26.274 + void m32() { 26.275 + try { 26.276 + nothing(); 26.277 + } 26.278 + catch(RuntimeException exc) { } 26.279 + catch(Error exc) { } 26.280 + catch(Throwable exc) { } //6: ok; latest: unreachable 26.281 + } 26.282 + 26.283 + void m33() { 26.284 + try { 26.285 + checked(); 26.286 + } 26.287 + catch(InterruptedException exc) { } //ok 26.288 + } 26.289 + 26.290 + void m34() { 26.291 + try { 26.292 + runtime(); 26.293 + } 26.294 + catch(InterruptedException exc) { } //never thrown in try 26.295 + } 26.296 + 26.297 + void m35() { 26.298 + try { 26.299 + nothing(); 26.300 + } 26.301 + catch(InterruptedException exc) { } //never thrown in try 26.302 + } 26.303 +}
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/test/tools/javac/6558548/T6558548_6.out Sat Mar 26 00:11:34 2011 -0700 27.3 @@ -0,0 +1,9 @@ 27.4 +- compiler.warn.source.no.bootclasspath: 1.6 27.5 +T6558548.java:159:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 27.6 +T6558548.java:168:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 27.7 +T6558548.java:239:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 27.8 +T6558548.java:249:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 27.9 +T6558548.java:291:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 27.10 +T6558548.java:298:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 27.11 +6 errors 27.12 +1 warning
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/tools/javac/6558548/T6558548_latest.out Sat Mar 26 00:11:34 2011 -0700 28.3 @@ -0,0 +1,23 @@ 28.4 +T6558548.java:20:9: compiler.warn.unreachable.catch: java.io.FileNotFoundException 28.5 +T6558548.java:134:9: compiler.warn.unreachable.catch: java.lang.RuntimeException 28.6 +T6558548.java:142:9: compiler.warn.unreachable.catch: java.lang.RuntimeException 28.7 +T6558548.java:151:9: compiler.warn.unreachable.catch.1: java.lang.InterruptedException,java.lang.RuntimeException 28.8 +T6558548.java:159:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 28.9 +T6558548.java:160:9: compiler.warn.unreachable.catch: java.lang.RuntimeException 28.10 +T6558548.java:168:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 28.11 +T6558548.java:169:9: compiler.warn.unreachable.catch: java.lang.RuntimeException 28.12 +T6558548.java:185:9: compiler.warn.unreachable.catch: java.lang.RuntimeException 28.13 +T6558548.java:193:9: compiler.warn.unreachable.catch: java.lang.RuntimeException 28.14 +T6558548.java:211:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error 28.15 +T6558548.java:220:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error 28.16 +T6558548.java:230:9: compiler.warn.unreachable.catch.1: java.lang.InterruptedException,java.lang.RuntimeException,java.lang.Error 28.17 +T6558548.java:239:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 28.18 +T6558548.java:240:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error 28.19 +T6558548.java:249:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 28.20 +T6558548.java:250:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error 28.21 +T6558548.java:268:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error 28.22 +T6558548.java:277:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error 28.23 +T6558548.java:291:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 28.24 +T6558548.java:298:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException 28.25 +6 errors 28.26 +15 warnings
29.1 --- a/test/tools/javac/Diagnostics/6769027/T6769027.java Thu Mar 24 11:20:59 2011 -0700 29.2 +++ b/test/tools/javac/Diagnostics/6769027/T6769027.java Sat Mar 26 00:11:34 2011 -0700 29.3 @@ -1,5 +1,5 @@ 29.4 /* 29.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 29.6 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 29.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.8 * 29.9 * This code is free software; you can redistribute it and/or modify it 29.10 @@ -261,7 +261,7 @@ 29.11 29.12 enum PositionKind { 29.13 NOPOS(Position.NOPOS, "- ", "error: "), 29.14 - POS(5, "Test.java:1:6: ", "/Test.java:1: "); 29.15 + POS(5, "Test.java:1:6: ", "/Test.java:1: error: "); 29.16 29.17 int pos; 29.18 String rawOutput;
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/test/tools/javac/Diagnostics/7010608/Test.java Sat Mar 26 00:11:34 2011 -0700 30.3 @@ -0,0 +1,92 @@ 30.4 +/* 30.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.7 + * 30.8 + * This code is free software; you can redistribute it and/or modify it 30.9 + * under the terms of the GNU General Public License version 2 only, as 30.10 + * published by the Free Software Foundation. 30.11 + * 30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 30.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 30.15 + * version 2 for more details (a copy is included in the LICENSE file that 30.16 + * accompanied this code). 30.17 + * 30.18 + * You should have received a copy of the GNU General Public License version 30.19 + * 2 along with this work; if not, write to the Free Software Foundation, 30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 30.21 + * 30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 30.23 + * or visit www.oracle.com if you need additional information or have any 30.24 + * questions. 30.25 + */ 30.26 + 30.27 +/* 30.28 + * @test 30.29 + * @bug 7010608 30.30 + * @summary the string 'error' should appear in error messages 30.31 + */ 30.32 + 30.33 +import java.io.*; 30.34 +import java.net.URI; 30.35 +import java.util.*; 30.36 +import javax.tools.*; 30.37 +import javax.tools.JavaCompiler.CompilationTask; 30.38 + 30.39 +public class Test { 30.40 + public static void main(String... args) throws Exception { 30.41 + new Test().run(); 30.42 + } 30.43 + 30.44 + void run() throws Exception { 30.45 + Locale prev = Locale.getDefault(); 30.46 + Locale.setDefault(Locale.ENGLISH); 30.47 + try { 30.48 + test(Arrays.<String>asList(), 30.49 + "myfo://test:1: error: cannot find symbol"); 30.50 + test(Arrays.asList("-XDdiagsFormat=OLD"), 30.51 + "myfo://test:1: cannot find symbol"); 30.52 + test(Arrays.asList("-XDoldDiags"), 30.53 + "myfo://test:1: cannot find symbol"); 30.54 + } finally { 30.55 + Locale.setDefault(prev); 30.56 + } 30.57 + } 30.58 + 30.59 + void test(List<String> options, String expect) throws Exception { 30.60 + System.err.println("test: " + options); 30.61 + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); 30.62 + StringWriter sw = new StringWriter(); 30.63 + PrintWriter pw = new PrintWriter(sw); 30.64 + JavaFileObject f = new MyFileObject("myfo://test", "class Bad { Missing x; }"); 30.65 + List<? extends JavaFileObject> files = Arrays.asList(f); 30.66 + CompilationTask task = javac.getTask(pw, null, null, options, null, files); 30.67 + boolean ok = task.call(); 30.68 + pw.close(); 30.69 + String out = sw.toString(); 30.70 + if (!out.isEmpty()) 30.71 + System.err.println(out); 30.72 + if (ok) 30.73 + throw new Exception("Compilation succeeded unexpectedly"); 30.74 + if (!out.contains(expect)) 30.75 + throw new Exception("expected text not found: " + expect); 30.76 + } 30.77 + 30.78 + class MyFileObject extends SimpleJavaFileObject { 30.79 + MyFileObject(String uri, String text) { 30.80 + super(URI.create(uri), JavaFileObject.Kind.SOURCE); 30.81 + this.text = text; 30.82 + } 30.83 + @Override 30.84 + public String getName() { 30.85 + return uri.toString(); 30.86 + } 30.87 + @Override 30.88 + public String getCharContent(boolean ignoreEncodingErrors) { 30.89 + return text; 30.90 + } 30.91 + final String text; 30.92 + } 30.93 +} 30.94 + 30.95 +
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/tools/javac/annotations/TestAnnotationPackageInfo.java Sat Mar 26 00:11:34 2011 -0700 31.3 @@ -0,0 +1,87 @@ 31.4 +/* 31.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 + * 31.8 + * This code is free software; you can redistribute it and/or modify it 31.9 + * under the terms of the GNU General Public License version 2 only, as 31.10 + * published by the Free Software Foundation. 31.11 + * 31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.15 + * version 2 for more details (a copy is included in the LICENSE file that 31.16 + * accompanied this code). 31.17 + * 31.18 + * You should have received a copy of the GNU General Public License version 31.19 + * 2 along with this work; if not, write to the Free Software Foundation, 31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.21 + * 31.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 31.23 + * or visit www.oracle.com if you need additional information or have any 31.24 + * questions. 31.25 + */ 31.26 + 31.27 +/* 31.28 + * @test 31.29 + * @bug 6993311 31.30 + * @summary annotations on packages are not validated 31.31 + */ 31.32 + 31.33 +import java.io.*; 31.34 +import java.net.*; 31.35 +import java.util.*; 31.36 +import javax.tools.*; 31.37 +import com.sun.source.util.*; 31.38 + 31.39 +public class TestAnnotationPackageInfo { 31.40 + public static void main(String... args) throws Exception { 31.41 + new TestAnnotationPackageInfo().run(); 31.42 + } 31.43 + 31.44 + static class MyFileObject extends SimpleJavaFileObject { 31.45 + private String text; 31.46 + public MyFileObject(String fileName, String text) { 31.47 + super(URI.create("myfo:/" + fileName), JavaFileObject.Kind.SOURCE); 31.48 + this.text = text; 31.49 + } 31.50 + @Override 31.51 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 31.52 + return text; 31.53 + } 31.54 + } 31.55 + 31.56 + public void run() throws Exception { 31.57 + final String bootPath = System.getProperty("sun.boot.class.path"); 31.58 + final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 31.59 + assert tool != null; 31.60 + 31.61 + JavaFileObject test_java = new MyFileObject("test/Test.java", 31.62 + "package test; public @interface Test {\n" + 31.63 + " public int mandatory();\n" + 31.64 + "}\n"); 31.65 + 31.66 + JavaFileObject package_info_java = new MyFileObject("test/package-info.java", 31.67 + "@Test package test;"); 31.68 + 31.69 + DiagnosticCollector<JavaFileObject> coll = new DiagnosticCollector<JavaFileObject>(); 31.70 + 31.71 + List<String> options = Arrays.asList("-bootclasspath", bootPath); 31.72 + List<? extends JavaFileObject> files = Arrays.asList(test_java, package_info_java); 31.73 + JavacTask ct = (JavacTask)tool.getTask(null, null, coll, options, null, files); 31.74 + ct.analyze(); 31.75 + 31.76 + String expectedCode = "compiler.err.annotation.missing.default.value"; 31.77 + List<Diagnostic<? extends JavaFileObject>> diags = coll.getDiagnostics(); 31.78 + switch (diags.size()) { 31.79 + case 0: 31.80 + throw new Exception("no diagnostics reported"); 31.81 + case 1: 31.82 + String code = diags.get(0).getCode(); 31.83 + if (code.equals(expectedCode)) 31.84 + return; 31.85 + throw new Exception("unexpected diag: " + diags.get(0)); 31.86 + default: 31.87 + throw new Exception("unexpected diags reported: " + diags); 31.88 + } 31.89 + } 31.90 +}
32.1 --- a/test/tools/javac/annotations/pos/package-info.java Thu Mar 24 11:20:59 2011 -0700 32.2 +++ b/test/tools/javac/annotations/pos/package-info.java Sat Mar 26 00:11:34 2011 -0700 32.3 @@ -1,5 +1,5 @@ 32.4 /* 32.5 - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. 32.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 32.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.8 * 32.9 * This code is free software; you can redistribute it and/or modify it 32.10 @@ -23,12 +23,12 @@ 32.11 32.12 /* 32.13 * @test 32.14 - * @bug 4901290 32.15 + * @bug 4901290 6993311 32.16 * @summary Package annotations 32.17 * @author gafter 32.18 * 32.19 * @compile package-info.java 32.20 */ 32.21 32.22 -@java.lang.annotation.Documented 32.23 +@Deprecated 32.24 package foo.bar;
33.1 --- a/test/tools/javac/api/6411310/Test.java Thu Mar 24 11:20:59 2011 -0700 33.2 +++ b/test/tools/javac/api/6411310/Test.java Sat Mar 26 00:11:34 2011 -0700 33.3 @@ -153,14 +153,12 @@ 33.4 Context c = new Context(); 33.5 Options options = Options.instance(c); 33.6 33.7 - if (useOptimizedZip) { 33.8 - options.put("useOptimizedZip", "true"); 33.9 - } 33.10 + options.put("useOptimizedZip", Boolean.toString(useOptimizedZip)); 33.11 33.12 - if (!useSymbolFile) { 33.13 - options.put("ignore.symbol.file", "true"); 33.14 - } 33.15 - return new JavacFileManager(c, false, null); 33.16 + if (!useSymbolFile) { 33.17 + options.put("ignore.symbol.file", "true"); 33.18 + } 33.19 + return new JavacFileManager(c, false, null); 33.20 } 33.21 33.22 File createDir(String name, String... entries) throws Exception {
34.1 --- a/test/tools/javac/api/6557752/T6557752.java Thu Mar 24 11:20:59 2011 -0700 34.2 +++ b/test/tools/javac/api/6557752/T6557752.java Sat Mar 26 00:11:34 2011 -0700 34.3 @@ -118,7 +118,8 @@ 34.4 34.5 Types types = task.getTypes(); 34.6 34.7 - if (types.asElement(trees.getOriginalType((ErrorType)typeMirror)) != null) { 34.8 + str1 = types.asElement(trees.getOriginalType((ErrorType)typeMirror)).toString(); 34.9 + if (!str1.equals("FooBar")) { 34.10 throw new AssertionError("Types.asElement() error!"); 34.11 } 34.12 foundError = true;
35.1 --- a/test/tools/javac/api/T6838467.java Thu Mar 24 11:20:59 2011 -0700 35.2 +++ b/test/tools/javac/api/T6838467.java Sat Mar 26 00:11:34 2011 -0700 35.3 @@ -178,12 +178,10 @@ 35.4 return fm; 35.5 } 35.6 35.7 - JavacFileManager createFileManager(boolean useOptimedZipIndex) { 35.8 + JavacFileManager createFileManager(boolean useOptimizedZip) { 35.9 Context ctx = new Context(); 35.10 - if (useOptimedZipIndex) { 35.11 - Options options = Options.instance(ctx); 35.12 - options.put("useOptimizedZip", "true"); 35.13 - } 35.14 + Options options = Options.instance(ctx); 35.15 + options.put("useOptimizedZip", Boolean.toString(useOptimizedZip)); 35.16 return new JavacFileManager(ctx, false, null); 35.17 } 35.18
36.1 --- a/test/tools/javac/api/T6877206.java Thu Mar 24 11:20:59 2011 -0700 36.2 +++ b/test/tools/javac/api/T6877206.java Sat Mar 26 00:11:34 2011 -0700 36.3 @@ -168,9 +168,7 @@ 36.4 JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) { 36.5 Context ctx = new Context(); 36.6 Options options = Options.instance(ctx); 36.7 - if (useOptimizedZip) { 36.8 - options.put("useOptimizedZip", "true"); 36.9 - } 36.10 + options.put("useOptimizedZip", Boolean.toString(useOptimizedZip)); 36.11 if (!useSymbolFile) { 36.12 options.put("ignore.symbol.file", "true"); 36.13 }
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 37.2 +++ b/test/tools/javac/api/TestJavacTask_Lock.java Sat Mar 26 00:11:34 2011 -0700 37.3 @@ -0,0 +1,111 @@ 37.4 +/* 37.5 + * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. 37.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.7 + * 37.8 + * This code is free software; you can redistribute it and/or modify it 37.9 + * under the terms of the GNU General Public License version 2 only, as 37.10 + * published by the Free Software Foundation. 37.11 + * 37.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 37.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 37.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 37.15 + * version 2 for more details (a copy is included in the LICENSE file that 37.16 + * accompanied this code). 37.17 + * 37.18 + * You should have received a copy of the GNU General Public License version 37.19 + * 2 along with this work; if not, write to the Free Software Foundation, 37.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 37.21 + * 37.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 37.23 + * or visit www.oracle.com if you need additional information or have any 37.24 + * questions. 37.25 + */ 37.26 + 37.27 +/* 37.28 + * @test 37.29 + * @bug 7026509 37.30 + * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations 37.31 + */ 37.32 + 37.33 +import java.io.*; 37.34 +import java.util.*; 37.35 +import javax.tools.*; 37.36 +import javax.tools.JavaCompiler.CompilationTask; 37.37 +import com.sun.source.util.*; 37.38 + 37.39 +public class TestJavacTask_Lock { 37.40 + public static void main(String... args) throws Exception { 37.41 + new TestJavacTask_Lock().run(); 37.42 + } 37.43 + 37.44 + enum MethodKind { 37.45 + CALL { 37.46 + int test(CompilationTask t) { 37.47 + boolean ok = t.call(); 37.48 + if (!ok) 37.49 + throw new Error("compilation failed"); 37.50 + return 1; 37.51 + } 37.52 + }, 37.53 + PARSE { 37.54 + int test(CompilationTask t) { 37.55 + try { 37.56 + ((JavacTask) t).parse(); 37.57 + return 1; 37.58 + } catch (IOException ex) { 37.59 + throw new Error(ex); 37.60 + } 37.61 + } 37.62 + 37.63 + }; 37.64 + abstract int test(CompilationTask t); 37.65 + } 37.66 + 37.67 + JavaCompiler comp; 37.68 + StandardJavaFileManager fm; 37.69 + 37.70 + void run() throws Exception { 37.71 + comp = ToolProvider.getSystemJavaCompiler(); 37.72 + fm = comp.getStandardFileManager(null, null, null); 37.73 + 37.74 + for (MethodKind first: MethodKind.values()) { 37.75 + for (MethodKind second: MethodKind.values()) { 37.76 + test(first, second); 37.77 + } 37.78 + } 37.79 + 37.80 + if (errors > 0) 37.81 + throw new Exception(errors + " errors found"); 37.82 + } 37.83 + 37.84 + void test(MethodKind first, MethodKind second) { 37.85 + System.err.println("test: " + first + ", " + second); 37.86 + File testSrc = new File(System.getProperty("test.src")); 37.87 + String thisClassName = TestJavacTask_Lock.class.getName(); 37.88 + Iterable<? extends JavaFileObject> files = 37.89 + fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java")); 37.90 + File tmpDir = new File(first + "_" + second); 37.91 + tmpDir.mkdirs(); 37.92 + List<String> options = Arrays.asList( "-d", tmpDir.getPath() ); 37.93 + CompilationTask t = comp.getTask(null, fm, null, options, null, files); 37.94 + 37.95 + try { 37.96 + first.test(t); 37.97 + second.test(t); 37.98 + error("No exception thrown"); 37.99 + } catch (IllegalStateException e) { 37.100 + System.err.println("Expected exception caught: " + e); 37.101 + } catch (Exception e) { 37.102 + error("Unexpected exception caught: " + e); 37.103 + e.printStackTrace(System.err); 37.104 + } 37.105 + 37.106 + } 37.107 + 37.108 + void error(String msg) { 37.109 + System.err.println("Error: " + msg); 37.110 + errors++; 37.111 + } 37.112 + 37.113 + int errors; 37.114 +}
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 38.2 +++ b/test/tools/javac/api/TestJavacTask_Multiple.java Sat Mar 26 00:11:34 2011 -0700 38.3 @@ -0,0 +1,118 @@ 38.4 +/* 38.5 + * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. 38.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.7 + * 38.8 + * This code is free software; you can redistribute it and/or modify it 38.9 + * under the terms of the GNU General Public License version 2 only, as 38.10 + * published by the Free Software Foundation. 38.11 + * 38.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 38.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 38.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38.15 + * version 2 for more details (a copy is included in the LICENSE file that 38.16 + * accompanied this code). 38.17 + * 38.18 + * You should have received a copy of the GNU General Public License version 38.19 + * 2 along with this work; if not, write to the Free Software Foundation, 38.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 38.21 + * 38.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 38.23 + * or visit www.oracle.com if you need additional information or have any 38.24 + * questions. 38.25 + */ 38.26 + 38.27 +/* 38.28 + * @test 38.29 + * @bug 7026509 38.30 + * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations 38.31 + */ 38.32 + 38.33 +import java.io.*; 38.34 +import java.util.*; 38.35 +import javax.tools.*; 38.36 +import javax.tools.JavaCompiler.CompilationTask; 38.37 +import com.sun.source.util.*; 38.38 + 38.39 +public class TestJavacTask_Multiple { 38.40 + public static void main(String... args) throws Exception { 38.41 + new TestJavacTask_Multiple().run(); 38.42 + } 38.43 + 38.44 + final int MAX_TASKS = 3; 38.45 + 38.46 + enum TestKind { 38.47 + CALL { 38.48 + int test(CompilationTask t) { 38.49 + boolean ok = t.call(); 38.50 + if (!ok) 38.51 + throw new Error("compilation failed"); 38.52 + return 1; 38.53 + } 38.54 + }, 38.55 + PARSE { 38.56 + int test(CompilationTask t) { 38.57 + try { 38.58 + ((JavacTask) t).parse(); 38.59 + return 1; 38.60 + } catch (IOException ex) { 38.61 + throw new Error(ex); 38.62 + } 38.63 + } 38.64 + 38.65 + }; 38.66 + abstract int test(CompilationTask t); 38.67 + } 38.68 + 38.69 + int count; 38.70 + 38.71 + void run() throws Exception { 38.72 + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); 38.73 + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); 38.74 + for (TestKind tk: TestKind.values()) { 38.75 + test(comp, fm, tk); 38.76 + } 38.77 + 38.78 + int expect = TestKind.values().length * MAX_TASKS; 38.79 + if (count != expect) { 38.80 + throw new Exception("Unexpected number of tests completed: " + count 38.81 + + ", expected: " + expect); 38.82 + } 38.83 + 38.84 + } 38.85 + 38.86 + void test(JavaCompiler comp, StandardJavaFileManager fm, TestKind tk) { 38.87 + System.err.println("test " + tk); 38.88 + File testSrc = new File(System.getProperty("test.src")); 38.89 + String thisClassName = TestJavacTask_Multiple.class.getName(); 38.90 + Iterable<? extends JavaFileObject> files = 38.91 + fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java")); 38.92 + 38.93 + List<CompilationTask> tasks = new ArrayList<CompilationTask>(); 38.94 + for (int i = 1; i <= MAX_TASKS; i++) { 38.95 + File tmpDir = new File(tk + "_" + i); 38.96 + tmpDir.mkdirs(); 38.97 + List<String> options = Arrays.asList( "-d", tmpDir.getPath() ); 38.98 + CompilationTask t = comp.getTask(null, fm, null, options, null, files); 38.99 + ((JavacTask) t).setTaskListener(createTaskListener(tk, i)); 38.100 + tasks.add(t); 38.101 + } 38.102 + 38.103 + for (CompilationTask t: tasks) 38.104 + count += tk.test(t); 38.105 + 38.106 + System.err.println(); 38.107 + } 38.108 + 38.109 + TaskListener createTaskListener(final TestKind tk, final int i) { 38.110 + return new TaskListener() { 38.111 + 38.112 + public void started(TaskEvent e) { 38.113 + System.err.println(tk + "." + i + ": " + e + " started"); 38.114 + } 38.115 + 38.116 + public void finished(TaskEvent e) { 38.117 + System.err.println(tk + "." + i + ": " + e + " finished"); 38.118 + } 38.119 + }; 38.120 + } 38.121 +}
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/test/tools/javac/api/TestJavacTask_ParseAttrGen.java Sat Mar 26 00:11:34 2011 -0700 39.3 @@ -0,0 +1,127 @@ 39.4 +/* 39.5 + * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. 39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.7 + * 39.8 + * This code is free software; you can redistribute it and/or modify it 39.9 + * under the terms of the GNU General Public License version 2 only, as 39.10 + * published by the Free Software Foundation. 39.11 + * 39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.15 + * version 2 for more details (a copy is included in the LICENSE file that 39.16 + * accompanied this code). 39.17 + * 39.18 + * You should have received a copy of the GNU General Public License version 39.19 + * 2 along with this work; if not, write to the Free Software Foundation, 39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.21 + * 39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 39.23 + * or visit www.oracle.com if you need additional information or have any 39.24 + * questions. 39.25 + */ 39.26 + 39.27 +/* 39.28 + * @test 39.29 + * @bug 7026509 39.30 + * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations 39.31 + */ 39.32 + 39.33 +import java.io.*; 39.34 +import java.util.*; 39.35 +import javax.lang.model.element.*; 39.36 +import javax.tools.*; 39.37 +import com.sun.source.tree.*; 39.38 +import com.sun.source.util.*; 39.39 + 39.40 +public class TestJavacTask_ParseAttrGen { 39.41 + public static void main(String... args) throws Exception { 39.42 + new TestJavacTask_ParseAttrGen().run(); 39.43 + } 39.44 + 39.45 + JavaCompiler comp; 39.46 + StandardJavaFileManager fm; 39.47 + 39.48 + void run() throws Exception { 39.49 + comp = ToolProvider.getSystemJavaCompiler(); 39.50 + fm = comp.getStandardFileManager(null, null, null); 39.51 + 39.52 + final boolean[] booleanValues = { false, true }; 39.53 + for (boolean pk: booleanValues) { 39.54 + for (boolean ak: booleanValues) { 39.55 + for (boolean gk: booleanValues) { 39.56 + test(pk, ak, gk); 39.57 + } 39.58 + } 39.59 + } 39.60 + } 39.61 + 39.62 + void test(boolean pk, boolean ak, boolean gk) throws Exception { 39.63 + if (!pk && !ak && !gk) // nothing to do 39.64 + return; 39.65 + 39.66 + System.err.println("test: pk:" + pk + ", ak:" + ak + ", gk: " + gk); 39.67 + File testSrc = new File(System.getProperty("test.src")); 39.68 + String thisClassName = TestJavacTask_ParseAttrGen.class.getName(); 39.69 + Iterable<? extends JavaFileObject> files = 39.70 + fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java")); 39.71 + File tmpDir = new File((pk ? "p" : "") + (ak ? "a" : "") + (gk ? "g" : "")); 39.72 + tmpDir.mkdirs(); 39.73 + fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir)); 39.74 + JavacTask t = (JavacTask) comp.getTask(null, fm, null, null, null, files); 39.75 + //t.setTaskListener(createTaskListener()); 39.76 + 39.77 + try { 39.78 + if (pk) { 39.79 + Iterable<? extends CompilationUnitTree> trees = t.parse(); 39.80 + System.err.println(count(trees) + " trees parsed"); 39.81 + } 39.82 + 39.83 + if (ak) { 39.84 + Iterable<? extends Element> elems = t.analyze(); 39.85 + System.err.println(count(elems) + " elements analyzed"); 39.86 + } 39.87 + 39.88 + if (gk) { 39.89 + Iterable<? extends JavaFileObject> classfiles = t.generate(); 39.90 + System.err.println(count(classfiles) + " class files generated"); 39.91 + } 39.92 + } catch (IOException e) { 39.93 + error("unexpected exception caught: " + e); 39.94 + } 39.95 + 39.96 + File[] genFiles = tmpDir.listFiles(); 39.97 + int expect = (gk ? 2 : 0); // main class and anon class for TaskListener 39.98 + if (genFiles.length != expect) 39.99 + error("unexpected number of files generated: " + genFiles.length 39.100 + + ", expected: " + expect); 39.101 + 39.102 + System.err.println(); 39.103 + } 39.104 + 39.105 + TaskListener createTaskListener() { 39.106 + return new TaskListener() { 39.107 + public void started(TaskEvent e) { 39.108 + System.err.println(e + " started"); 39.109 + } 39.110 + 39.111 + public void finished(TaskEvent e) { 39.112 + System.err.println(e + " finished"); 39.113 + } 39.114 + }; 39.115 + } 39.116 + 39.117 + <T> int count(Iterable<T> items) { 39.118 + int count = 0; 39.119 + for (T item: items) 39.120 + count++; 39.121 + return count; 39.122 + } 39.123 + 39.124 + void error(String msg) { 39.125 + System.err.println("Error: " + msg); 39.126 + errors++; 39.127 + } 39.128 + 39.129 + int errors; 39.130 +}
40.1 --- a/test/tools/javac/diags/examples/CountError.java Thu Mar 24 11:20:59 2011 -0700 40.2 +++ b/test/tools/javac/diags/examples/CountError.java Sat Mar 26 00:11:34 2011 -0700 40.3 @@ -1,5 +1,5 @@ 40.4 /* 40.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 40.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 40.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 40.8 * 40.9 * This code is free software; you can redistribute it and/or modify it 40.10 @@ -23,6 +23,7 @@ 40.11 40.12 // key: compiler.misc.count.error 40.13 // key: compiler.err.unreported.exception.need.to.catch.or.throw 40.14 +// key: compiler.err.error 40.15 // run: backdoor 40.16 40.17 class CountError {
41.1 --- a/test/tools/javac/diags/examples/CountErrorPlural.java Thu Mar 24 11:20:59 2011 -0700 41.2 +++ b/test/tools/javac/diags/examples/CountErrorPlural.java Sat Mar 26 00:11:34 2011 -0700 41.3 @@ -1,5 +1,5 @@ 41.4 /* 41.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 41.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 41.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.8 * 41.9 * This code is free software; you can redistribute it and/or modify it 41.10 @@ -23,6 +23,7 @@ 41.11 41.12 // key: compiler.misc.count.error.plural 41.13 // key: compiler.err.unreported.exception.need.to.catch.or.throw 41.14 +// key: compiler.err.error 41.15 // run: backdoor 41.16 41.17 class CountErrorPlural {
42.1 --- a/test/tools/javac/diags/examples/IdentifierExpected.java Thu Mar 24 11:20:59 2011 -0700 42.2 +++ b/test/tools/javac/diags/examples/IdentifierExpected.java Sat Mar 26 00:11:34 2011 -0700 42.3 @@ -1,5 +1,5 @@ 42.4 /* 42.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 42.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 42.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.8 * 42.9 * This code is free software; you can redistribute it and/or modify it 42.10 @@ -25,6 +25,7 @@ 42.11 // key: compiler.err.expected 42.12 // key: compiler.err.invalid.binary.number 42.13 // key: compiler.misc.count.error.plural 42.14 +// key: compiler.err.error 42.15 // run: backdoor 42.16 42.17 class IdentifierExpected {
43.1 --- a/test/tools/javac/diags/examples/KindnameClass.java Thu Mar 24 11:20:59 2011 -0700 43.2 +++ b/test/tools/javac/diags/examples/KindnameClass.java Sat Mar 26 00:11:34 2011 -0700 43.3 @@ -25,6 +25,7 @@ 43.4 // key: compiler.err.cant.resolve.location 43.5 // key: compiler.misc.location 43.6 // key: compiler.misc.count.error 43.7 +// key: compiler.err.error 43.8 // run: backdoor 43.9 43.10 class KindnameClass {
44.1 --- a/test/tools/javac/diags/examples/KindnameConstructor.java Thu Mar 24 11:20:59 2011 -0700 44.2 +++ b/test/tools/javac/diags/examples/KindnameConstructor.java Sat Mar 26 00:11:34 2011 -0700 44.3 @@ -1,5 +1,5 @@ 44.4 /* 44.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 44.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 44.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 44.8 * 44.9 * This code is free software; you can redistribute it and/or modify it 44.10 @@ -28,6 +28,7 @@ 44.11 // key: compiler.misc.arg.length.mismatch 44.12 // key: compiler.misc.no.conforming.assignment.exists 44.13 // key: compiler.misc.count.error.plural 44.14 +// key: compiler.err.error 44.15 // run: backdoor 44.16 44.17 class KindnameConstructor {
45.1 --- a/test/tools/javac/diags/examples/KindnameMethod.java Thu Mar 24 11:20:59 2011 -0700 45.2 +++ b/test/tools/javac/diags/examples/KindnameMethod.java Sat Mar 26 00:11:34 2011 -0700 45.3 @@ -26,6 +26,7 @@ 45.4 // key: compiler.err.cant.resolve.location.args 45.5 // key: compiler.misc.location 45.6 // key: compiler.misc.count.error 45.7 +// key: compiler.err.error 45.8 // run: backdoor 45.9 45.10 class KindnameMethod {
46.1 --- a/test/tools/javac/diags/examples/KindnameVariable.java Thu Mar 24 11:20:59 2011 -0700 46.2 +++ b/test/tools/javac/diags/examples/KindnameVariable.java Sat Mar 26 00:11:34 2011 -0700 46.3 @@ -26,6 +26,7 @@ 46.4 // key: compiler.err.cant.resolve.location 46.5 // key: compiler.misc.location 46.6 // key: compiler.misc.count.error 46.7 +// key: compiler.err.error 46.8 // run: backdoor 46.9 46.10 class KindnameVariable {
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/tools/javac/diags/examples/UnreachableCatch.java Sat Mar 26 00:11:34 2011 -0700 47.3 @@ -0,0 +1,35 @@ 47.4 +/* 47.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 47.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 47.7 + * 47.8 + * This code is free software; you can redistribute it and/or modify it 47.9 + * under the terms of the GNU General Public License version 2 only, as 47.10 + * published by the Free Software Foundation. 47.11 + * 47.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 47.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 47.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47.15 + * version 2 for more details (a copy is included in the LICENSE file that 47.16 + * accompanied this code). 47.17 + * 47.18 + * You should have received a copy of the GNU General Public License version 47.19 + * 2 along with this work; if not, write to the Free Software Foundation, 47.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 47.21 + * 47.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 47.23 + * or visit www.oracle.com if you need additional information or have any 47.24 + * questions. 47.25 + */ 47.26 + 47.27 +// key: compiler.warn.unreachable.catch 47.28 + 47.29 +class UnreachableCatch { 47.30 + 47.31 + void test() { 47.32 + try { 47.33 + throw new java.io.FileNotFoundException(); 47.34 + } 47.35 + catch(java.io.FileNotFoundException exc) { } 47.36 + catch(java.io.IOException exc) { } //unreachable 47.37 + } 47.38 +}
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/tools/javac/diags/examples/UnreachableCatch1.java Sat Mar 26 00:11:34 2011 -0700 48.3 @@ -0,0 +1,36 @@ 48.4 +/* 48.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.7 + * 48.8 + * This code is free software; you can redistribute it and/or modify it 48.9 + * under the terms of the GNU General Public License version 2 only, as 48.10 + * published by the Free Software Foundation. 48.11 + * 48.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 48.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 48.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 48.15 + * version 2 for more details (a copy is included in the LICENSE file that 48.16 + * accompanied this code). 48.17 + * 48.18 + * You should have received a copy of the GNU General Public License version 48.19 + * 2 along with this work; if not, write to the Free Software Foundation, 48.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 48.21 + * 48.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 48.23 + * or visit www.oracle.com if you need additional information or have any 48.24 + * questions. 48.25 + */ 48.26 + 48.27 +// key: compiler.warn.unreachable.catch.1 48.28 + 48.29 +class UnreachableCatch1 { 48.30 + 48.31 + void test() { 48.32 + try { 48.33 + throw new IllegalArgumentException(); 48.34 + } 48.35 + catch(Error err) { } 48.36 + catch(RuntimeException rex) { } 48.37 + catch(Throwable t) { } //unreachable 48.38 + } 48.39 +}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/tools/javac/file/zip/T6836682.java Sat Mar 26 00:11:34 2011 -0700 49.3 @@ -0,0 +1,241 @@ 49.4 +/* 49.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 49.7 + * 49.8 + * This code is free software; you can redistribute it and/or modify it 49.9 + * under the terms of the GNU General Public License version 2 only, as 49.10 + * published by the Free Software Foundation. 49.11 + * 49.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 49.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 49.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 49.15 + * version 2 for more details (a copy is included in the LICENSE file that 49.16 + * accompanied this code). 49.17 + * 49.18 + * You should have received a copy of the GNU General Public License version 49.19 + * 2 along with this work; if not, write to the Free Software Foundation, 49.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 49.21 + * 49.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 49.23 + * or visit www.oracle.com if you need additional information or have any 49.24 + * questions. 49.25 + */ 49.26 + 49.27 +/* 49.28 + * @test 49.29 + * @bug 6836682 7025988 49.30 + * @summary JavacFileManager handling of zip64 archives (Scenario A and B) 49.31 + * @compile -XDignore.symbol.file T6836682.java Utils.java 49.32 + * @run main T6836682 49.33 + */ 49.34 +/* 49.35 + * This test consists of two scenarios: 49.36 + * 49.37 + * Scenario A: create a jar with entries exceeding 64K, and see if the javac 49.38 + * can handle this large jar on the classpath. Generally this test completes 49.39 + * within a minute 49.40 + * 49.41 + * Scenario B: create a jar with a large enough file exceeding 4GB, and 49.42 + * similarly test javac. This test is known to be slow and problematic on 49.43 + * certain operating systems, thus this test can be selected by passing a 49.44 + * property through jtreg as follows: 49.45 + * -javaoptions=-DT6836682.testScenarioB=true. 49.46 + * Note this test will only run iff all the disk requirements are met at runtime. 49.47 + */ 49.48 +import java.io.BufferedInputStream; 49.49 +import java.io.BufferedOutputStream; 49.50 +import java.io.File; 49.51 +import java.io.FileInputStream; 49.52 +import java.io.FileOutputStream; 49.53 +import java.io.IOException; 49.54 +import java.io.OutputStream; 49.55 +import java.nio.file.Files; 49.56 +import java.nio.file.Path; 49.57 +import java.util.zip.CRC32; 49.58 +import java.util.zip.ZipEntry; 49.59 +import java.util.zip.ZipOutputStream; 49.60 + 49.61 +public class T6836682 { 49.62 + 49.63 + private static final long GIGA = 1024 * 1024 * 1024; 49.64 + private static final int BUFFER_LEN = Short.MAX_VALUE * 2; 49.65 + 49.66 + static long getCount(long minlength) { 49.67 + return (minlength / BUFFER_LEN) + 1; 49.68 + } 49.69 + 49.70 + static long computeCRC(long minlength) { 49.71 + CRC32 crc = new CRC32(); 49.72 + byte[] buffer = new byte[BUFFER_LEN]; 49.73 + long count = getCount(minlength); 49.74 + for (long i = 0; i < count; i++) { 49.75 + crc.update(buffer); 49.76 + } 49.77 + return crc.getValue(); 49.78 + } 49.79 + 49.80 + static long computeCRC(File inFile) throws IOException { 49.81 + byte[] buffer = new byte[8192]; 49.82 + CRC32 crc = new CRC32(); 49.83 + FileInputStream fis = null; 49.84 + BufferedInputStream bis = null; 49.85 + try { 49.86 + fis = new FileInputStream(inFile); 49.87 + bis = new BufferedInputStream(fis); 49.88 + int n = bis.read(buffer); 49.89 + while (n > 0) { 49.90 + crc.update(buffer, 0, n); 49.91 + n = bis.read(buffer); 49.92 + } 49.93 + } finally { 49.94 + Utils.close(bis); 49.95 + Utils.close(fis); 49.96 + } 49.97 + return crc.getValue(); 49.98 + } 49.99 + 49.100 + static void createLargeFile(OutputStream os, long minlength) throws IOException { 49.101 + byte[] buffer = new byte[BUFFER_LEN]; 49.102 + long count = getCount(minlength); 49.103 + for (long i = 0; i < count; i++) { 49.104 + os.write(buffer); 49.105 + } 49.106 + os.flush(); 49.107 + } 49.108 + 49.109 + static void createJarWithLargeFile(File jarFile, File javaFile, 49.110 + long minlength) throws IOException { 49.111 + Utils.createClassFile(javaFile, null, true); 49.112 + File classFile = new File(Utils.getClassFileName(javaFile)); 49.113 + ZipOutputStream zos = null; 49.114 + BufferedOutputStream bos = null; 49.115 + FileInputStream fis = null; 49.116 + try { 49.117 + zos = new ZipOutputStream(new FileOutputStream(jarFile)); 49.118 + zos.setLevel(ZipOutputStream.STORED); 49.119 + zos.setMethod(0); 49.120 + bos = new BufferedOutputStream(zos); 49.121 + 49.122 + ZipEntry ze = new ZipEntry("large.data"); 49.123 + ze.setCompressedSize(getCount(minlength) * BUFFER_LEN); 49.124 + ze.setSize(getCount(minlength) * BUFFER_LEN); 49.125 + ze.setCrc(computeCRC(minlength)); 49.126 + ze.setMethod(ZipEntry.STORED); 49.127 + zos.putNextEntry(ze); 49.128 + createLargeFile(bos, minlength); 49.129 + 49.130 + ze = new ZipEntry(classFile.getName()); 49.131 + ze.setCompressedSize(classFile.length()); 49.132 + ze.setSize(classFile.length()); 49.133 + ze.setCrc(computeCRC(classFile)); 49.134 + ze.setMethod(ZipEntry.STORED); 49.135 + zos.putNextEntry(ze); 49.136 + fis = new FileInputStream(classFile); 49.137 + Utils.copyStream(fis, bos); 49.138 + bos.flush(); 49.139 + zos.closeEntry(); 49.140 + } finally { 49.141 + Utils.close(bos); 49.142 + Utils.close(zos); 49.143 + Utils.close(fis); 49.144 + } 49.145 + // deleted to prevent accidental linkage 49.146 + new File(Utils.getClassFileName(javaFile)).delete(); 49.147 + } 49.148 + 49.149 + static void createLargeJar(File jarFile, File javaFile) throws IOException { 49.150 + File classFile = new File(Utils.getClassFileName(javaFile)); 49.151 + Utils.createClassFile(javaFile, null, true); 49.152 + ZipOutputStream zos = null; 49.153 + FileInputStream fis = null; 49.154 + final int MAX = Short.MAX_VALUE * 2 + 10; 49.155 + ZipEntry ze = null; 49.156 + try { 49.157 + zos = new ZipOutputStream(new FileOutputStream(jarFile)); 49.158 + zos.setLevel(ZipOutputStream.STORED); 49.159 + zos.setMethod(ZipOutputStream.STORED); 49.160 + for (int i = 0; i < MAX ; i++) { 49.161 + ze = new ZipEntry("X" + i + ".txt"); 49.162 + ze.setSize(0); 49.163 + ze.setCompressedSize(0); 49.164 + ze.setCrc(0); 49.165 + zos.putNextEntry(ze); 49.166 + } 49.167 + 49.168 + // add a class file 49.169 + ze = new ZipEntry(classFile.getName()); 49.170 + ze.setCompressedSize(classFile.length()); 49.171 + ze.setSize(classFile.length()); 49.172 + ze.setCrc(computeCRC(classFile)); 49.173 + zos.putNextEntry(ze); 49.174 + fis = new FileInputStream(classFile); 49.175 + Utils.copyStream(fis, zos); 49.176 + } finally { 49.177 + Utils.close(zos); 49.178 + Utils.close(fis); 49.179 + // deleted to prevent accidental linkage 49.180 + new File(Utils.getClassFileName(javaFile)).delete(); 49.181 + } 49.182 + } 49.183 + 49.184 + // a jar with entries exceeding 64k + a class file for the existential test 49.185 + public static void testScenarioA(String... args) throws IOException { 49.186 + File largeJar = new File("large.jar"); 49.187 + File javaFile = new File("Foo.java"); 49.188 + createLargeJar(largeJar, javaFile); 49.189 + 49.190 + File testFile = new File("Bar.java"); 49.191 + try { 49.192 + Utils.createJavaFile(testFile, javaFile); 49.193 + if (!Utils.compile("-doe", "-verbose", "-cp", 49.194 + largeJar.getAbsolutePath(), testFile.getAbsolutePath())) { 49.195 + throw new IOException("test failed"); 49.196 + } 49.197 + } finally { 49.198 + Utils.deleteFile(largeJar); 49.199 + } 49.200 + } 49.201 + 49.202 + // a jar with an enormous file + a class file for the existential test 49.203 + public static void testScenarioB(String... args) throws IOException { 49.204 + final File largeJar = new File("huge.jar"); 49.205 + final File javaFile = new File("Foo.java"); 49.206 + 49.207 + final Path path = largeJar.getAbsoluteFile().getParentFile().toPath(); 49.208 + final long available = Files.getFileStore(path).getUsableSpace(); 49.209 + final long MAX_VALUE = 0xFFFF_FFFFL; 49.210 + 49.211 + final long absolute = MAX_VALUE + 1L; 49.212 + final long required = (long)(absolute * 1.1); // pad for sundries 49.213 + System.out.println("\tavailable: " + available / GIGA + " GB"); 49.214 + System.out.println("\trequired: " + required / GIGA + " GB"); 49.215 + 49.216 + if (available > required) { 49.217 + createJarWithLargeFile(largeJar, javaFile, absolute); 49.218 + File testFile = new File("Bar.java"); 49.219 + Utils.createJavaFile(testFile, javaFile); 49.220 + try { 49.221 + if (!Utils.compile("-doe", "-verbose", "-cp", 49.222 + largeJar.getAbsolutePath(), testFile.getAbsolutePath())) { 49.223 + throw new IOException("test failed"); 49.224 + } 49.225 + } finally { 49.226 + Utils.deleteFile(largeJar); 49.227 + } 49.228 + } else { 49.229 + System.out.println("Warning: testScenarioB passes vacuously," + 49.230 + " requirements exceeds available space"); 49.231 + } 49.232 + } 49.233 + 49.234 + public static void main(String... args) throws IOException { 49.235 + testScenarioA(); 49.236 + System.out.println("testScenarioA: PASS"); 49.237 + if (Boolean.getBoolean("T6836682.testScenarioB")) { 49.238 + testScenarioB(); 49.239 + System.out.println("testScenarioB: PASS"); 49.240 + } else { 49.241 + System.out.println("Warning: testScenarioB, large file test skipped"); 49.242 + } 49.243 + } 49.244 +}
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/tools/javac/file/zip/T6865530.java Sat Mar 26 00:11:34 2011 -0700 50.3 @@ -0,0 +1,66 @@ 50.4 +/* 50.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. 50.11 + * 50.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.15 + * version 2 for more details (a copy is included in the LICENSE file that 50.16 + * accompanied this code). 50.17 + * 50.18 + * You should have received a copy of the GNU General Public License version 50.19 + * 2 along with this work; if not, write to the Free Software Foundation, 50.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.21 + * 50.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.23 + * or visit www.oracle.com if you need additional information or have any 50.24 + * questions. 50.25 + */ 50.26 + 50.27 +/* 50.28 + * @test 50.29 + * @bug 6865530 50.30 + * @summary ensure JavacFileManager handles non-standard zipfiles. 50.31 + * @compile -XDignore.symbol.file T6865530.java 50.32 + * @run main T6865530 50.33 + */ 50.34 + 50.35 + 50.36 +import java.io.File; 50.37 + 50.38 + 50.39 +public class T6865530 { 50.40 + 50.41 + public static void main(String... args) throws Exception { 50.42 + File badFile = new File("bad.exe"); 50.43 + File testJar = new File("test.jar"); 50.44 + File fooJava = new File("Foo.java"); 50.45 + File barJava = new File("Bar.java"); 50.46 + 50.47 + // create a jar by compiling a file, and append the jar to some 50.48 + // arbitrary data to offset the start of the zip/jar archive 50.49 + Utils.createJavaFile(fooJava); 50.50 + Utils.compile("-doe", "-verbose", fooJava.getName()); 50.51 + String[] jarArgs = { 50.52 + "cvf", testJar.getAbsolutePath(), "Foo.class" 50.53 + }; 50.54 + Utils.jarTool.run(jarArgs); 50.55 + Utils.cat(badFile, fooJava, testJar); 50.56 + 50.57 + // create test file and use the above file as a classpath 50.58 + Utils.createJavaFile(barJava); 50.59 + try { 50.60 + if (!Utils.compile("-doe", "-verbose", "-cp", badFile.getAbsolutePath(), "Bar.java")) { 50.61 + throw new RuntimeException("test fails javac did not compile"); 50.62 + } 50.63 + } finally { 50.64 + Utils.deleteFile(badFile); 50.65 + Utils.deleteFile(testJar); 50.66 + } 50.67 + } 50.68 +} 50.69 +
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/tools/javac/file/zip/Utils.java Sat Mar 26 00:11:34 2011 -0700 51.3 @@ -0,0 +1,131 @@ 51.4 +/* 51.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. 51.11 + * 51.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.15 + * version 2 for more details (a copy is included in the LICENSE file that 51.16 + * accompanied this code). 51.17 + * 51.18 + * You should have received a copy of the GNU General Public License version 51.19 + * 2 along with this work; if not, write to the Free Software Foundation, 51.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.21 + * 51.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.23 + * or visit www.oracle.com if you need additional information or have any 51.24 + * questions. 51.25 + */ 51.26 + 51.27 +import java.io.BufferedInputStream; 51.28 +import java.io.BufferedOutputStream; 51.29 +import java.io.Closeable; 51.30 +import java.io.File; 51.31 +import java.io.FileInputStream; 51.32 +import java.io.FileOutputStream; 51.33 +import java.io.IOException; 51.34 +import java.io.InputStream; 51.35 +import java.io.OutputStream; 51.36 +import java.io.PrintStream; 51.37 + 51.38 +public class Utils { 51.39 + 51.40 + static final sun.tools.jar.Main jarTool = 51.41 + new sun.tools.jar.Main(System.out, System.err, "jar-tool"); 51.42 + 51.43 + static final com.sun.tools.javac.Main javac = 51.44 + new com.sun.tools.javac.Main(); 51.45 + 51.46 + private Utils(){} 51.47 + 51.48 + public static boolean compile(String... args) { 51.49 + return javac.compile(args) == 0; 51.50 + } 51.51 + 51.52 + public static void createClassFile(File javaFile, File superClass, 51.53 + boolean delete) throws IOException { 51.54 + createJavaFile(javaFile, superClass); 51.55 + if (!compile(javaFile.getName())) { 51.56 + throw new RuntimeException("compile failed unexpectedly"); 51.57 + } 51.58 + if (delete) javaFile.delete(); 51.59 + } 51.60 + 51.61 + public static void createJavaFile(File outFile) throws IOException { 51.62 + createJavaFile(outFile, null); 51.63 + } 51.64 + 51.65 + public static void createJavaFile(File outFile, File superClass) throws IOException { 51.66 + PrintStream ps = null; 51.67 + String srcStr = "public class " + getSimpleName(outFile) + " "; 51.68 + if (superClass != null) { 51.69 + srcStr = srcStr.concat("extends " + getSimpleName(superClass) + " "); 51.70 + } 51.71 + srcStr = srcStr.concat("{}"); 51.72 + try { 51.73 + FileOutputStream fos = new FileOutputStream(outFile); 51.74 + ps = new PrintStream(fos); 51.75 + ps.println(srcStr); 51.76 + } finally { 51.77 + close(ps); 51.78 + } 51.79 + } 51.80 + 51.81 + static String getClassFileName(File javaFile) { 51.82 + return javaFile.getName().endsWith(".java") 51.83 + ? javaFile.getName().replace(".java", ".class") 51.84 + : null; 51.85 + } 51.86 + 51.87 + static String getSimpleName(File inFile) { 51.88 + String fname = inFile.getName(); 51.89 + return fname.substring(0, fname.indexOf(".")); 51.90 + } 51.91 + 51.92 + public static void copyStream(InputStream in, OutputStream out) throws IOException { 51.93 + byte[] buf = new byte[8192]; 51.94 + int n = in.read(buf); 51.95 + while (n > 0) { 51.96 + out.write(buf, 0, n); 51.97 + n = in.read(buf); 51.98 + } 51.99 + } 51.100 + 51.101 + public static void close(Closeable c) { 51.102 + if (c != null) { 51.103 + try { 51.104 + c.close(); 51.105 + } catch (IOException ignore) {} 51.106 + } 51.107 + } 51.108 + 51.109 + public static void deleteFile(File f) { 51.110 + if (!f.delete()) { 51.111 + throw new RuntimeException("could not delete file: " + f.getAbsolutePath()); 51.112 + } 51.113 + } 51.114 + 51.115 + public static void cat(File output, File... files) throws IOException { 51.116 + BufferedInputStream bis = null; 51.117 + BufferedOutputStream bos = null; 51.118 + FileOutputStream fos = null; 51.119 + try { 51.120 + fos = new FileOutputStream(output); 51.121 + bos = new BufferedOutputStream(fos); 51.122 + for (File x : files) { 51.123 + FileInputStream fis = new FileInputStream(x); 51.124 + bis = new BufferedInputStream(fis); 51.125 + copyStream(bis, bos); 51.126 + Utils.close(bis); 51.127 + } 51.128 + } finally { 51.129 + Utils.close(bis); 51.130 + Utils.close(bos); 51.131 + Utils.close(fos); 51.132 + } 51.133 + } 51.134 +}
52.1 --- a/test/tools/javac/lib/JavacTestingAbstractProcessor.java Thu Mar 24 11:20:59 2011 -0700 52.2 +++ b/test/tools/javac/lib/JavacTestingAbstractProcessor.java Sat Mar 26 00:11:34 2011 -0700 52.3 @@ -1,5 +1,5 @@ 52.4 /* 52.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 52.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 52.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 52.8 * 52.9 * This code is free software; you can redistribute it and/or modify it 52.10 @@ -24,8 +24,6 @@ 52.11 import java.util.*; 52.12 import javax.annotation.processing.*; 52.13 import javax.lang.model.SourceVersion; 52.14 -import static javax.lang.model.SourceVersion.*; 52.15 -import javax.lang.model.element.*; 52.16 import javax.lang.model.util.*; 52.17 52.18 /**
53.1 --- a/test/tools/javac/processing/6430209/b6341534.java Thu Mar 24 11:20:59 2011 -0700 53.2 +++ b/test/tools/javac/processing/6430209/b6341534.java Sat Mar 26 00:11:34 2011 -0700 53.3 @@ -1,5 +1,5 @@ 53.4 /* 53.5 - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 53.6 + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 53.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.8 * 53.9 * This code is free software; you can redistribute it and/or modify it 53.10 @@ -56,7 +56,9 @@ 53.11 // on round 1, expect errorRaised == false && processingOver == false 53.12 // on round 2, expect errorRaised == true && processingOver == true 53.13 if( renv.errorRaised() != renv.processingOver()) { 53.14 - messager.printMessage(ERROR, "FAILED"); 53.15 + messager.printMessage(ERROR, "FAILED: round:" + r 53.16 + + ", errorRaised:" + renv.errorRaised() 53.17 + + ", processingOver:" + renv.processingOver()); 53.18 } 53.19 return true; 53.20 }
54.1 --- a/test/tools/javac/processing/6994946/SemanticErrorTest.2.out Thu Mar 24 11:20:59 2011 -0700 54.2 +++ b/test/tools/javac/processing/6994946/SemanticErrorTest.2.out Sat Mar 26 00:11:34 2011 -0700 54.3 @@ -1,4 +1,4 @@ 54.4 SemanticErrorTest.java:11:46: compiler.err.repeated.interface 54.5 - compiler.err.proc.messager: Deliberate Error 54.6 SemanticErrorTest.java:11:46: compiler.err.repeated.interface 54.7 -1 error 54.8 +2 errors
55.1 --- a/test/tools/javac/processing/environment/round/TestContext.java Thu Mar 24 11:20:59 2011 -0700 55.2 +++ b/test/tools/javac/processing/environment/round/TestContext.java Sat Mar 26 00:11:34 2011 -0700 55.3 @@ -1,5 +1,5 @@ 55.4 /* 55.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 55.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 55.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 55.8 * 55.9 * This code is free software; you can redistribute it and/or modify it 55.10 @@ -34,7 +34,6 @@ 55.11 import java.util.*; 55.12 import javax.annotation.processing.*; 55.13 import javax.lang.model.element.*; 55.14 -import javax.tools.*; 55.15 import static javax.tools.Diagnostic.Kind.*; 55.16 55.17 import com.sun.source.util.Trees;
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/test/tools/javac/processing/errors/TestErrorCount.java Sat Mar 26 00:11:34 2011 -0700 56.3 @@ -0,0 +1,46 @@ 56.4 +/* 56.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 56.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.7 + * 56.8 + * This code is free software; you can redistribute it and/or modify it 56.9 + * under the terms of the GNU General Public License version 2 only, as 56.10 + * published by the Free Software Foundation. 56.11 + * 56.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 56.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 56.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 56.15 + * version 2 for more details (a copy is included in the LICENSE file that 56.16 + * accompanied this code). 56.17 + * 56.18 + * You should have received a copy of the GNU General Public License version 56.19 + * 2 along with this work; if not, write to the Free Software Foundation, 56.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 56.21 + * 56.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 56.23 + * or visit www.oracle.com if you need additional information or have any 56.24 + * questions. 56.25 + */ 56.26 + 56.27 +/* 56.28 + * @test 56.29 + * @bug 6988079 56.30 + * @summary Errors reported via Messager.printMessage(ERROR,"error message") are not tallied correctly 56.31 + * @library ../../lib 56.32 + * @build JavacTestingAbstractProcessor TestErrorCount 56.33 + * @compile/fail/ref=TestErrorCount.out -XDrawDiagnostics -processor TestErrorCount TestErrorCount.java 56.34 + */ 56.35 + 56.36 +import java.io.*; 56.37 +import java.util.*; 56.38 +import javax.annotation.processing.*; 56.39 +import javax.lang.model.element.*; 56.40 +import javax.tools.*; 56.41 + 56.42 +public class TestErrorCount extends JavacTestingAbstractProcessor { 56.43 + @Override 56.44 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 56.45 + messager.printMessage(Diagnostic.Kind.ERROR, "intentional error"); 56.46 + return true; 56.47 + } 56.48 +} 56.49 +
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57.2 +++ b/test/tools/javac/processing/errors/TestErrorCount.out Sat Mar 26 00:11:34 2011 -0700 57.3 @@ -0,0 +1,3 @@ 57.4 +- compiler.err.proc.messager: intentional error 57.5 +- compiler.err.proc.messager: intentional error 57.6 +2 errors
58.1 --- a/test/tools/javac/processing/filer/TestPackageInfo.java Thu Mar 24 11:20:59 2011 -0700 58.2 +++ b/test/tools/javac/processing/filer/TestPackageInfo.java Sat Mar 26 00:11:34 2011 -0700 58.3 @@ -1,5 +1,5 @@ 58.4 /* 58.5 - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 58.6 + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 58.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 58.8 * 58.9 * This code is free software; you can redistribute it and/or modify it 58.10 @@ -23,7 +23,7 @@ 58.11 58.12 /* 58.13 * @test 58.14 - * @bug 6380018 6392177 58.15 + * @bug 6380018 6392177 6993311 58.16 * @summary Test the ability to create and process package-info.java files 58.17 * @author Joseph D. Darcy 58.18 * @library ../../lib 58.19 @@ -60,7 +60,7 @@ 58.20 58.21 // Verify annotations are as expected 58.22 Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>(); 58.23 - expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings")); 58.24 + expectedAnnotations.add(eltUtils.getTypeElement("java.lang.Deprecated")); 58.25 58.26 if (!roundEnv.processingOver()) { 58.27 System.out.println("\nRound " + round); 58.28 @@ -90,7 +90,7 @@ 58.29 } catch(FilerException fe) {} 58.30 58.31 PrintWriter pw = new PrintWriter(filer.createSourceFile("foo.package-info").openWriter()); 58.32 - pw.println("@SuppressWarnings(\"\")"); 58.33 + pw.println("@Deprecated"); 58.34 pw.println("package foo;"); 58.35 pw.close(); 58.36
59.1 --- a/test/tools/javac/processing/filer/foo/bar/package-info.java Thu Mar 24 11:20:59 2011 -0700 59.2 +++ b/test/tools/javac/processing/filer/foo/bar/package-info.java Sat Mar 26 00:11:34 2011 -0700 59.3 @@ -1,5 +1,5 @@ 59.4 /* 59.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 59.6 + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 59.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 59.8 * 59.9 * This code is free software; you can redistribute it and/or modify it 59.10 @@ -24,5 +24,5 @@ 59.11 /** 59.12 * Javadoc for the foo.bar package! 59.13 */ 59.14 -@SuppressWarnings("deprecation") 59.15 +@Deprecated 59.16 package foo.bar;
60.1 --- a/test/tools/javac/processing/model/element/TestAnonClassNames.java Thu Mar 24 11:20:59 2011 -0700 60.2 +++ b/test/tools/javac/processing/model/element/TestAnonClassNames.java Sat Mar 26 00:11:34 2011 -0700 60.3 @@ -1,5 +1,5 @@ 60.4 /* 60.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 60.6 + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 60.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 60.8 * 60.9 * This code is free software; you can redistribute it and/or modify it 60.10 @@ -23,7 +23,7 @@ 60.11 60.12 /* 60.13 * @test 60.14 - * @bug 6449781 60.15 + * @bug 6449781 6930508 60.16 * @summary Test that reported names of anonymous classes are non-null. 60.17 * @author Joseph D. Darcy 60.18 * @library ../../../lib 60.19 @@ -93,6 +93,7 @@ 60.20 TestAnonClassNames.class, 60.21 }; 60.22 60.23 + List<String> names = new ArrayList<String>(); 60.24 for(Class<?> clazz : classes) { 60.25 String name = clazz.getName(); 60.26 Nesting anno = clazz.getAnnotation(Nesting.class); 60.27 @@ -100,7 +101,14 @@ 60.28 clazz.getName(), 60.29 anno == null ? "(unset/ANONYMOUS)" : anno.value()); 60.30 testClassName(name); 60.31 + names.add(name); 60.32 } 60.33 + 60.34 + // test all names together 60.35 + testClassNames(names); 60.36 + 60.37 + if (errors > 0) 60.38 + throw new RuntimeException(errors + " errors occurred"); 60.39 } 60.40 60.41 /** 60.42 @@ -109,15 +117,23 @@ 60.43 * input classes are modeled as elements. 60.44 */ 60.45 static void testClassName(String className) { 60.46 - JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); 60.47 - List<String> classNames = new ArrayList<String>(); 60.48 - classNames.add(className); 60.49 + testClassNames(Arrays.asList(className)); 60.50 + } 60.51 + 60.52 + /** 60.53 + * Perform annotation processing on a list of class file names and verify 60.54 + * the existence of different flavors of class names when the 60.55 + * input classes are modeled as elements. 60.56 + */ 60.57 + static void testClassNames(List<String> classNames) { 60.58 + System.out.println("test: " + classNames); 60.59 60.60 List<String> options = new ArrayList<String>(); 60.61 options.add("-proc:only"); 60.62 options.add("-classpath"); 60.63 options.add(System.getProperty("test.classes")); 60.64 60.65 + JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); 60.66 JavaCompiler.CompilationTask compileTask = 60.67 javaCompiler.getTask(null, // Output 60.68 null, // File manager 60.69 @@ -130,9 +146,16 @@ 60.70 compileTask.setProcessors(processors); 60.71 Boolean goodResult = compileTask.call(); 60.72 if (!goodResult) { 60.73 - throw new RuntimeException("Errors found during compile."); 60.74 + error("Errors found during compile."); 60.75 } 60.76 } 60.77 + 60.78 + static int errors = 0; 60.79 + 60.80 + static void error(String msg) { 60.81 + System.out.println("Error: " + msg); 60.82 + errors++; 60.83 + } 60.84 } 60.85 60.86 @Retention(RUNTIME)
61.1 --- a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java Thu Mar 24 11:20:59 2011 -0700 61.2 +++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java Sat Mar 26 00:11:34 2011 -0700 61.3 @@ -24,7 +24,7 @@ 61.4 61.5 /* 61.6 * @test 61.7 - * @bug 6639645 61.8 + * @bug 6639645 7026414 61.9 * @summary Modeling type implementing missing interfaces 61.10 * @library ../../../../lib 61.11 * @build JavacTestingAbstractProcessor TestMissingElement 61.12 @@ -112,6 +112,7 @@ 61.13 61.14 @Override 61.15 public String visitDeclared(DeclaredType t, Void ignore) { 61.16 + checkEqual(t.asElement(), types.asElement(t)); 61.17 String s = asString(t.asElement()); 61.18 List<? extends TypeMirror> args = t.getTypeArguments(); 61.19 if (!args.isEmpty()) 61.20 @@ -179,6 +180,13 @@ 61.21 return (e != null && e.getKind() == ElementKind.PACKAGE 61.22 && ((PackageElement) e).isUnnamed()); 61.23 } 61.24 + 61.25 + void checkEqual(Element e1, Element e2) { 61.26 + if (e1 != e2) { 61.27 + throw new AssertionError("elements not equal as expected: " 61.28 + + e1 + ", " + e2); 61.29 + } 61.30 + } 61.31 } 61.32 61.33
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 62.2 +++ b/test/tools/javac/processing/options/testCommandLineClasses/Test.java Sat Mar 26 00:11:34 2011 -0700 62.3 @@ -0,0 +1,106 @@ 62.4 +/* 62.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 62.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 62.7 + * 62.8 + * This code is free software; you can redistribute it and/or modify it 62.9 + * under the terms of the GNU General Public License version 2 only, as 62.10 + * published by the Free Software Foundation. 62.11 + * 62.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 62.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 62.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 62.15 + * version 2 for more details (a copy is included in the LICENSE file that 62.16 + * accompanied this code). 62.17 + * 62.18 + * You should have received a copy of the GNU General Public License version 62.19 + * 2 along with this work; if not, write to the Free Software Foundation, 62.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 62.21 + * 62.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 62.23 + * or visit www.oracle.com if you need additional information or have any 62.24 + * questions. 62.25 + */ 62.26 + 62.27 +/* 62.28 + * @test 62.29 + * @bug 6930508 62.30 + * @summary Passing nested class names on javac command line interfere with subsequent name -> class lookup 62.31 + * @library ../../../lib 62.32 + * @build JavacTestingAbstractProcessor p.NestedExamples Test 62.33 + * @run main Test 62.34 + */ 62.35 + 62.36 +import java.io.*; 62.37 +import java.util.*; 62.38 +import javax.annotation.processing.RoundEnvironment; 62.39 +import javax.lang.model.element.TypeElement; 62.40 +import javax.lang.model.util.ElementFilter; 62.41 +import javax.tools.*; 62.42 + 62.43 +import p.NestedExamples; 62.44 + 62.45 +public class Test extends JavacTestingAbstractProcessor { 62.46 + public static void main(String... args) throws Exception { 62.47 + new Test().run(); 62.48 + } 62.49 + 62.50 + void run() throws Exception { 62.51 + NestedExamples e = new NestedExamples(); 62.52 + List<String> names = getNames(e.getClasses()); 62.53 + test(names); 62.54 + test(reverse(names)); 62.55 + names = Arrays.asList(e.getClassNames()); 62.56 + test(names); 62.57 + test(reverse(names)); 62.58 + 62.59 + if (errors > 0) 62.60 + throw new RuntimeException(errors + " errors occurred"); 62.61 + } 62.62 + 62.63 + List<String> getNames(Class<?>[] classes) { 62.64 + List<String> names = new ArrayList<String>(); 62.65 + for (Class<?> c: classes) 62.66 + names.add(c.getName()); 62.67 + return names; 62.68 + } 62.69 + 62.70 + void test(List<String> names) throws Exception { 62.71 + System.err.println("test: " + names); 62.72 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 62.73 + StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null); 62.74 + File testClasses = new File(System.getProperty("test.classes")); 62.75 + fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses)); 62.76 + JavaCompiler.CompilationTask task = compiler.getTask( 62.77 + null, null, null, Arrays.asList("-proc:only"), names, null); 62.78 + task.setProcessors(Arrays.asList(new Test())); 62.79 + boolean ok = task.call(); 62.80 + if (!ok) 62.81 + error("compilation failed"); 62.82 + System.err.println(); 62.83 + } 62.84 + 62.85 + <T> List<T> reverse(List<T> list) { 62.86 + List<T> newList = new ArrayList<T>(list); 62.87 + Collections.reverse(newList); 62.88 + return newList; 62.89 + } 62.90 + 62.91 + int errors = 0; 62.92 + 62.93 + void error(String msg) { 62.94 + System.out.println("Error: " + msg); 62.95 + errors++; 62.96 + } 62.97 + 62.98 + //---------- 62.99 + 62.100 + public boolean process(Set<? extends TypeElement> annotations, 62.101 + RoundEnvironment roundEnv) { 62.102 + if (!roundEnv.processingOver()) { 62.103 + for (TypeElement typeElt : ElementFilter.typesIn(roundEnv.getRootElements())) { 62.104 + messager.printMessage(Diagnostic.Kind.NOTE, "processing " + typeElt); 62.105 + } 62.106 + } 62.107 + return true; 62.108 + } 62.109 +}
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 63.2 +++ b/test/tools/javac/processing/options/testCommandLineClasses/p/NestedExamples.java Sat Mar 26 00:11:34 2011 -0700 63.3 @@ -0,0 +1,63 @@ 63.4 +/* 63.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 63.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 63.7 + * 63.8 + * This code is free software; you can redistribute it and/or modify it 63.9 + * under the terms of the GNU General Public License version 2 only, as 63.10 + * published by the Free Software Foundation. 63.11 + * 63.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 63.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 63.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 63.15 + * version 2 for more details (a copy is included in the LICENSE file that 63.16 + * accompanied this code). 63.17 + * 63.18 + * You should have received a copy of the GNU General Public License version 63.19 + * 2 along with this work; if not, write to the Free Software Foundation, 63.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 63.21 + * 63.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 63.23 + * or visit www.oracle.com if you need additional information or have any 63.24 + * questions. 63.25 + */ 63.26 + 63.27 +package p; 63.28 + 63.29 +public class NestedExamples { 63.30 + static class MemberClass1 { } 63.31 + 63.32 + class MemberClass2 { } 63.33 + 63.34 + class Win$$AtVegas { } // Class with funny name. 63.35 + 63.36 + public Class<?>[] getClasses() { 63.37 + class LocalClass { } 63.38 + 63.39 + Object o = new Object() { // An anonymous class 63.40 + @Override 63.41 + public String toString() { 63.42 + return "I have no name!"; 63.43 + } 63.44 + }; 63.45 + 63.46 + return new Class<?>[] { 63.47 + NestedExamples.class, 63.48 + MemberClass1.class, 63.49 + MemberClass2.class, 63.50 + Win$$AtVegas.class, 63.51 + LocalClass.class, 63.52 + o.getClass() 63.53 + }; 63.54 + } 63.55 + 63.56 + public String[] getClassNames() { 63.57 + return new String[] { 63.58 + "p.NestedExamples", 63.59 + "p.NestedExamples.MemberClass1", 63.60 + "p.NestedExamples.MemberClass2", 63.61 + "p.NestedExamples.Win$$AtVegas" 63.62 + }; 63.63 + } 63.64 +} 63.65 + 63.66 +
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 64.2 +++ b/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java Sat Mar 26 00:11:34 2011 -0700 64.3 @@ -0,0 +1,74 @@ 64.4 +/* 64.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 64.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 64.7 + * 64.8 + * This code is free software; you can redistribute it and/or modify it 64.9 + * under the terms of the GNU General Public License version 2 only, as 64.10 + * published by the Free Software Foundation. 64.11 + * 64.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 64.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 64.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 64.15 + * version 2 for more details (a copy is included in the LICENSE file that 64.16 + * accompanied this code). 64.17 + * 64.18 + * You should have received a copy of the GNU General Public License version 64.19 + * 2 along with this work; if not, write to the Free Software Foundation, 64.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 64.21 + * 64.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 64.23 + * or visit www.oracle.com if you need additional information or have any 64.24 + * questions. 64.25 + */ 64.26 + 64.27 +/* 64.28 + * @test 64.29 + * @bug 6987384 64.30 + * @summary -XprintProcessorRoundsInfo message printed with different timing than previous 64.31 + * @library ../../../lib 64.32 + * @build JavacTestingAbstractProcessor Test 64.33 + * @compile/fail/ref=Test.out -XDrawDiagnostics -XprintProcessorInfo -Werror -proc:only -processor Test Test.java 64.34 + */ 64.35 + 64.36 +import java.io.*; 64.37 +import java.util.*; 64.38 +import javax.annotation.processing.*; 64.39 +import javax.lang.model.*; 64.40 +import javax.lang.model.element.*; 64.41 +import javax.lang.model.util.*; 64.42 +import javax.tools.*; 64.43 + 64.44 +public class Test extends JavacTestingAbstractProcessor { 64.45 + final int MAX_ROUNDS = 3; 64.46 + int round = 0; 64.47 + 64.48 + @Override 64.49 + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 64.50 + round++; 64.51 + messager.printMessage(Diagnostic.Kind.NOTE, "round " + round); 64.52 + if (round <= MAX_ROUNDS) 64.53 + generateSource("Gen" + round); 64.54 + if (roundEnv.processingOver()) 64.55 + messager.printMessage(Diagnostic.Kind.WARNING, "last round"); 64.56 + return true; 64.57 + } 64.58 + 64.59 + void generateSource(String name) { 64.60 + String text = "class " + name + " { }\n"; 64.61 + 64.62 + // avoid try-with-resources so test can be run on older builds 64.63 + try { 64.64 + Writer out = filer.createSourceFile(name).openWriter(); 64.65 + try { 64.66 + out.write(text); 64.67 + } finally { 64.68 + out.close(); 64.69 + } 64.70 + } catch (IOException e) { 64.71 + throw new Error(e); 64.72 + } 64.73 + } 64.74 +} 64.75 + 64.76 + 64.77 +
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 65.2 +++ b/test/tools/javac/processing/options/testPrintProcessorInfo/Test.out Sat Mar 26 00:11:34 2011 -0700 65.3 @@ -0,0 +1,13 @@ 65.4 +Processor Test matches [java.lang.Override] and returns true. 65.5 +- compiler.note.proc.messager: round 1 65.6 +Processor Test matches [] and returns true. 65.7 +- compiler.note.proc.messager: round 2 65.8 +Processor Test matches [] and returns true. 65.9 +- compiler.note.proc.messager: round 3 65.10 +Processor Test matches [] and returns true. 65.11 +- compiler.note.proc.messager: round 4 65.12 +- compiler.note.proc.messager: round 5 65.13 +- compiler.warn.proc.messager: last round 65.14 +- compiler.err.warnings.and.werror 65.15 +1 error 65.16 +1 warning