--- a/langtools/make/build.xml Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/make/build.xml Thu Jun 30 14:19:25 2011 -0700
@@ -336,7 +336,9 @@
classpath="${dist.lib.dir}/javac.jar"
includeAntRuntime="no"
debug="${javac.debug}"
- debuglevel="${javac.debuglevel}"/>
+ debuglevel="${javac.debuglevel}">
+ <compilerarg line="${javac.lint.opts}"/>
+ </javac>
<java fork="true"
jvm="${target.java.home}/bin/java"
dir="test/tools/javac/diags"
@@ -857,7 +859,10 @@
srcdir="${make.tools.dir}/CompileProperties"
destdir="${build.toolclasses.dir}/"
classpath="${ant.core.lib}"
- includeantruntime="false"/>
+ bootclasspath="${boot.java.home}/jre/lib/rt.jar"
+ includeantruntime="false">
+ <compilerarg line="${javac.lint.opts}"/>
+ </javac>
<taskdef name="pcompile"
classname="CompilePropertiesTask"
classpath="${build.toolclasses.dir}/"/>
@@ -874,6 +879,7 @@
classpath="${ant.core.lib}"
includeantruntime="false">
<compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
+ <compilerarg line="${javac.lint.opts}"/>
</javac>
<taskdef name="genstubs"
classname="GenStubs$$Ant"
--- a/langtools/make/tools/CompileProperties/CompileProperties.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/make/tools/CompileProperties/CompileProperties.java Thu Jun 30 14:19:25 2011 -0700
@@ -222,13 +222,13 @@
sortedKeys.add((String)key);
}
Collections.sort(sortedKeys);
- Iterator keys = sortedKeys.iterator();
+ Iterator<String> keys = sortedKeys.iterator();
StringBuffer data = new StringBuffer();
while (keys.hasNext()) {
- Object key = keys.next();
- data.append(" { \"" + escape((String)key) + "\", \"" +
+ String key = keys.next();
+ data.append(" { \"" + escape(key) + "\", \"" +
escape((String)p.get(key)) + "\" },\n");
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Thu Jun 30 14:19:25 2011 -0700
@@ -64,8 +64,11 @@
/** 1.6 reports encoding problems as errors instead of warnings. */
JDK1_6("1.6"),
- /** 1.7 covers the to be determined language features that will be added in JDK 7. */
- JDK1_7("1.7");
+ /** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */
+ JDK1_7("1.7"),
+
+ /** 1.8 covers the to be determined language features that will be added in JDK 8. */
+ JDK1_8("1.8");
private static final Context.Key<Source> sourceKey
= new Context.Key<Source>();
@@ -92,19 +95,21 @@
tab.put("5", JDK1_5); // Make 5 an alias for 1.5
tab.put("6", JDK1_6); // Make 6 an alias for 1.6
tab.put("7", JDK1_7); // Make 7 an alias for 1.7
+ tab.put("8", JDK1_8); // Make 8 an alias for 1.8
}
private Source(String name) {
this.name = name;
}
- public static final Source DEFAULT = JDK1_7;
+ public static final Source DEFAULT = JDK1_8;
public static Source lookup(String name) {
return tab.get(name);
}
public Target requiredTarget() {
+ if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8;
if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7;
if (this.compareTo(JDK1_6) >= 0) return Target.JDK1_6;
if (this.compareTo(JDK1_5) >= 0) return Target.JDK1_5;
@@ -203,6 +208,8 @@
return RELEASE_6;
case JDK1_7:
return RELEASE_7;
+ case JDK1_8:
+ return RELEASE_8;
default:
return null;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jun 30 14:19:25 2011 -0700
@@ -3388,6 +3388,13 @@
}
@Override
+ public void visitAssignop(JCAssignOp that) {
+ if (that.operator == null)
+ that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
+ super.visitAssignop(that);
+ }
+
+ @Override
public void visitBinary(JCBinary that) {
if (that.operator == null)
that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java Thu Jun 30 14:19:25 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,10 @@
JDK1_6("1.6", 50, 0),
/** JDK 7. */
- JDK1_7("1.7", 51, 0);
+ JDK1_7("1.7", 51, 0),
+
+ /** JDK 8. */ // For now, a clone of 7
+ JDK1_8("1.8", 51, 0);
private static final Context.Key<Target> targetKey =
new Context.Key<Target>();
@@ -99,6 +102,7 @@
tab.put("5", JDK1_5);
tab.put("6", JDK1_6);
tab.put("7", JDK1_7);
+ tab.put("8", JDK1_8);
}
public final String name;
@@ -110,7 +114,7 @@
this.minorVersion = minorVersion;
}
- public static final Target DEFAULT = JDK1_7;
+ public static final Target DEFAULT = JDK1_8;
public static Target lookup(String name) {
return tab.get(name);
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Jun 30 14:19:25 2011 -0700
@@ -295,59 +295,24 @@
/**
* Use a service loader appropriate for the platform to provide an
- * iterator over annotations processors. If
- * java.util.ServiceLoader is present use it, otherwise, use
- * sun.misc.Service, otherwise fail if a loader is needed.
+ * iterator over annotations processors; fails if a loader is
+ * needed but unavailable.
*/
private class ServiceIterator implements Iterator<Processor> {
- // The to-be-wrapped iterator.
- private Iterator<?> iterator;
+ private Iterator<Processor> iterator;
private Log log;
- private Class<?> loaderClass;
- private boolean jusl;
- private Object loader;
+ private ServiceLoader<Processor> loader;
ServiceIterator(ClassLoader classLoader, Log log) {
- String loadMethodName;
-
this.log = log;
try {
try {
- loaderClass = Class.forName("java.util.ServiceLoader");
- loadMethodName = "load";
- jusl = true;
- } catch (ClassNotFoundException cnfe) {
- try {
- loaderClass = Class.forName("sun.misc.Service");
- loadMethodName = "providers";
- jusl = false;
- } catch (ClassNotFoundException cnfe2) {
- // Fail softly if a loader is not actually needed.
- this.iterator = handleServiceLoaderUnavailability("proc.no.service",
- null);
- return;
- }
+ loader = ServiceLoader.load(Processor.class, classLoader);
+ this.iterator = loader.iterator();
+ } catch (Exception e) {
+ // Fail softly if a loader is not actually needed.
+ this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
}
-
- // java.util.ServiceLoader.load or sun.misc.Service.providers
- Method loadMethod = loaderClass.getMethod(loadMethodName,
- Class.class,
- ClassLoader.class);
-
- Object result = loadMethod.invoke(null,
- Processor.class,
- classLoader);
-
- // For java.util.ServiceLoader, we have to call another
- // method to get the iterator.
- if (jusl) {
- loader = result; // Store ServiceLoader to call reload later
- Method m = loaderClass.getMethod("iterator");
- result = m.invoke(result); // serviceLoader.iterator();
- }
-
- // The result should now be an iterator.
- this.iterator = (Iterator<?>) result;
} catch (Throwable t) {
log.error("proc.service.problem");
throw new Abort(t);
@@ -357,25 +322,21 @@
public boolean hasNext() {
try {
return iterator.hasNext();
+ } catch(ServiceConfigurationError sce) {
+ log.error("proc.bad.config.file", sce.getLocalizedMessage());
+ throw new Abort(sce);
} catch (Throwable t) {
- if ("ServiceConfigurationError".
- equals(t.getClass().getSimpleName())) {
- log.error("proc.bad.config.file", t.getLocalizedMessage());
- }
throw new Abort(t);
}
}
public Processor next() {
try {
- return (Processor)(iterator.next());
+ return iterator.next();
+ } catch (ServiceConfigurationError sce) {
+ log.error("proc.bad.config.file", sce.getLocalizedMessage());
+ throw new Abort(sce);
} catch (Throwable t) {
- if ("ServiceConfigurationError".
- equals(t.getClass().getSimpleName())) {
- log.error("proc.bad.config.file", t.getLocalizedMessage());
- } else {
- log.error("proc.processor.constructor.error", t.getLocalizedMessage());
- }
throw new Abort(t);
}
}
@@ -385,11 +346,9 @@
}
public void close() {
- if (jusl) {
+ if (loader != null) {
try {
- // Call java.util.ServiceLoader.reload
- Method reloadMethod = loaderClass.getMethod("reload");
- reloadMethod.invoke(loader);
+ loader.reload();
} catch(Exception e) {
; // Ignore problems during a call to reload.
}
@@ -1516,6 +1475,14 @@
return context;
}
+ /**
+ * Internal use method to return the writer being used by the
+ * processing environment.
+ */
+ public PrintWriter getWriter() {
+ return context.get(Log.outKey);
+ }
+
public String toString() {
return "javac ProcessingEnvironment";
}
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Thu Jun 30 14:19:25 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,8 +48,7 @@
* deletion without notice.</b>
*/
@SupportedAnnotationTypes("*")
-// TODO: Change to version 7 based visitors when available
-@SupportedSourceVersion(SourceVersion.RELEASE_7)
+@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class PrintingProcessor extends AbstractProcessor {
PrintWriter writer;
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Jun 30 14:19:25 2011 -0700
@@ -637,8 +637,7 @@
Class names, ''{0}'', are only accepted if annotation processing is explicitly requested
compiler.err.proc.no.service=\
- A service loader class could not be found.\n\
- Either java.util.ServiceLoader or sun.misc.Service must be available.
+ A ServiceLoader was not usable and is required for annotation processing.
compiler.err.proc.processor.bad.option.name=\
Bad option name ''{0}'' provided by processor ''{1}''
@@ -647,9 +646,6 @@
compiler.err.proc.processor.cant.instantiate=\
Could not instantiate an instance of processor ''{0}''
-compiler.err.proc.processor.constructor.error=\
- Exception thrown while constructing Processor object: {0}
-
# 0: string
compiler.err.proc.processor.not.found=\
Annotation processor ''{0}'' not found
--- a/langtools/src/share/classes/javax/lang/model/SourceVersion.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/src/share/classes/javax/lang/model/SourceVersion.java Thu Jun 30 14:19:25 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -124,7 +124,15 @@
*
* @since 1.7
*/
- RELEASE_7;
+ RELEASE_7,
+
+ /**
+ * The version recognized by the Java Platform, Standard Edition
+ * 8.
+ *
+ * @since 1.8
+ */
+ RELEASE_8;
// Note that when adding constants for newer releases, the
// behavior of latest() and latestSupported() must be updated too.
@@ -135,7 +143,7 @@
* @return the latest source version that can be modeled
*/
public static SourceVersion latest() {
- return RELEASE_7;
+ return RELEASE_8;
}
private static final SourceVersion latestSupported = getLatestSupported();
@@ -143,9 +151,12 @@
private static SourceVersion getLatestSupported() {
try {
String specVersion = System.getProperty("java.specification.version");
- if ("1.7".equals(specVersion))
+
+ if ("1.8".equals(specVersion))
+ return RELEASE_8;
+ else if("1.7".equals(specVersion))
return RELEASE_7;
- else if ("1.6".equals(specVersion))
+ else if("1.6".equals(specVersion))
return RELEASE_6;
} catch (SecurityException se) {}
--- a/langtools/test/tools/javac/6330997/T6330997.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/test/tools/javac/6330997/T6330997.java Thu Jun 30 14:19:25 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,12 @@
/**
* @test
- * @bug 6330997
+ * @bug 6330997 7025789
* @summary javac should accept class files with major version of the next release
* @author Wei Tao
* @clean T1 T2
- * @compile -target 7 T1.java
- * @compile -target 7 T2.java
+ * @compile -target 8 T1.java
+ * @compile -target 8 T2.java
* @run main/othervm T6330997
*/
--- a/langtools/test/tools/javac/api/T6395981.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/test/tools/javac/api/T6395981.java Thu Jun 30 14:19:25 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,13 +23,13 @@
/*
* @test
- * @bug 6395981 6458819
+ * @bug 6395981 6458819 7025784
* @summary JavaCompilerTool and Tool must specify version of JLS and JVMS
* @author Peter von der Ah\u00e9
* @run main/fail T6395981
* @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6
* @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6
- * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7
+ * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8
*/
import java.util.EnumSet;
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Thu Jun 30 14:19:25 2011 -0700
@@ -31,7 +31,6 @@
compiler.err.proc.cant.create.loader # security exception from service loader
compiler.err.proc.no.service # JavacProcessingEnvironment: no service loader available
compiler.err.proc.processor.bad.option.name # cannot happen? masked by javac.err.invalid.A.key
-compiler.err.proc.processor.constructor.error
compiler.err.proc.service.problem # JavacProcessingEnvironment: catch Throwable from service loader
compiler.err.signature.doesnt.match.intf # UNUSED
compiler.err.signature.doesnt.match.supertype # UNUSED
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/failover/FailOver15.java Thu Jun 30 14:19:25 2011 -0700
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584 7060926
+ * @summary Attr.PostAttrAnalyzer misses a case
+ *
+ * @compile/fail/ref=FailOver15.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver15.java
+ */
+
+class Test {
+ void m() {
+ new UnknownClass<String, Void>() {
+ public String getString() {
+ String s = "";
+ s += "more";
+ return s;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/failover/FailOver15.out Thu Jun 30 14:19:25 2011 -0700
@@ -0,0 +1,4 @@
+FailOver15.java:17:10: compiler.err.expected: ';'
+FailOver15.java:11:13: compiler.err.cant.resolve.location: kindname.class, UnknownClass, , , (compiler.misc.location: kindname.class, Test, null)
+2 errors
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/TestSourceVersion.java Thu Jun 30 14:19:25 2011 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7025809
+ * @summary Test latest and latestSupported
+ * @author Joseph D. Darcy
+ */
+
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * Verify latest[Supported] behavior.
+ */
+public class TestSourceVersion {
+ public static void main(String... args) {
+ if (SourceVersion.latest() != RELEASE_8 ||
+ SourceVersion.latestSupported() != RELEASE_8)
+ throw new RuntimeException("Unexpected release value(s) found:\n" +
+ "latest:\t" + SourceVersion.latest() + "\n" +
+ "latestSupported:\t" + SourceVersion.latestSupported());
+ }
+}
--- a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java Thu Jun 30 14:19:25 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6376083 6376084 6458819
+ * @bug 6376083 6376084 6458819 7025784 7025786 7025789
* @summary Test that warnings about source versions are output as expected.
* @author Joseph D. Darcy
* @compile TestSourceVersionWarnings.java
@@ -35,7 +35,8 @@
* @compile/ref=gold_sv_warn_5_6.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 -Xlint:-options HelloWorld.java
* @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options HelloWorld.java
* @compile/ref=gold_unsp_warn.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options -Aunsupported HelloWorld.java
- * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 HelloWorld.java
+ * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 -Xlint:-options HelloWorld.java
+ * @compile/ref=gold_sv_none.out -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_8 -source 1.8 HelloWorld.java
*/
import java.util.Set;
@@ -51,7 +52,8 @@
/**
* This processor returns the supported source level as indicated by
* the "SourceLevel" option; therefore, don't use
- * JavacTestingAbstractProcessor which returns the latest source level.
+ * JavacTestingAbstractProcessor which returns the latest source
+ * level.
*/
@SupportedAnnotationTypes("*")
@SupportedOptions("SourceVersion")
--- a/langtools/test/tools/javac/quid/T6999438.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/test/tools/javac/quid/T6999438.java Thu Jun 30 14:19:25 2011 -0700
@@ -1,7 +1,7 @@
/* @test /nodynamiccopyright/
* @bug 6999438
* @summary remove support for exotic identifiers from JDK 7
- * @compile/fail/ref=T6999438.out -XDrawDiagnostics -source 7 T6999438.java
+ * @compile/fail/ref=T6999438.out -XDrawDiagnostics T6999438.java
*/
class Test {
--- a/langtools/test/tools/javac/util/T6597678.java Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/test/tools/javac/util/T6597678.java Thu Jun 30 14:19:25 2011 -0700
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 6597678
+ * @bug 6597678 6449184
* @summary Ensure Messages propogated between rounds
* @library ../lib
* @build JavacTestingAbstractProcessor T6597678
@@ -42,26 +42,28 @@
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JavacMessages;
+@SupportedOptions("WriterString")
public class T6597678 extends JavacTestingAbstractProcessor {
public static void main(String... args) throws Exception {
new T6597678().run();
}
-
void run() throws Exception {
String myName = T6597678.class.getSimpleName();
File testSrc = new File(System.getProperty("test.src"));
File file = new File(testSrc, myName + ".java");
- compile(
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ compile(sw, pw,
"-proc:only",
"-processor", myName,
+ "-AWriterString=" + pw.toString(),
file.getPath());
}
- void compile(String... args) throws Exception {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
+ void compile(StringWriter sw, PrintWriter pw, String... args) throws Exception {
int rc = com.sun.tools.javac.Main.compile(args, pw);
pw.close();
String out = sw.toString();
@@ -76,6 +78,7 @@
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
+ PrintWriter out = ((JavacProcessingEnvironment) processingEnv).getWriter();
Locale locale = context.get(Locale.class);
JavacMessages messages = context.get(JavacMessages.messagesKey);
@@ -83,9 +86,13 @@
if (round == 1) {
initialLocale = locale;
initialMessages = messages;
+ initialWriter = out;
+
+ checkEqual("writerString", out.toString().intern(), options.get("WriterString").intern());
} else {
checkEqual("locale", locale, initialLocale);
checkEqual("messages", messages, initialMessages);
+ checkEqual("writer", out, initialWriter);
}
return true;
@@ -102,4 +109,5 @@
int round = 0;
Locale initialLocale;
JavacMessages initialMessages;
+ PrintWriter initialWriter;
}
--- a/langtools/test/tools/javac/versions/check.sh Mon Jun 27 14:11:09 2011 -0700
+++ b/langtools/test/tools/javac/versions/check.sh Thu Jun 30 14:19:25 2011 -0700
@@ -22,7 +22,7 @@
#
# @test
-# @bug 4981566 5028634 5094412 6304984
+# @bug 4981566 5028634 5094412 6304984 7025786 7025789
# @summary Check interpretation of -target and -source options
# @build CheckClassFileVersion
# @run shell check.sh
@@ -65,9 +65,14 @@
check 51.0 -source 6
check 51.0 -source 1.7
check 51.0 -source 7
-check 51.0 -target 1.7
-check 51.0 -target 7
+check 51.0 -source 7 -target 1.7
+check 51.0 -source 7 -target 7
+# Update when class file version is revved
+check 51.0 -source 1.8
+check 51.0 -source 8
+check 51.0 -target 1.8
+check 51.0 -target 8
# Check source versions
@@ -96,6 +101,7 @@
checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
checksrc16() { checksrc15 $* ; }
checksrc17() { checksrc15 $* ; }
+checksrc18() { checksrc15 $* ; }
checksrc14 -source 1.4
checksrc14 -source 1.4 -target 1.5
@@ -108,16 +114,24 @@
checksrc16 -source 1.6 -target 1.6
checksrc16 -source 6 -target 6
-checksrc17
-checksrc17 -target 1.7
-checksrc17 -target 7
checksrc17 -source 1.7
checksrc17 -source 7
checksrc17 -source 1.7 -target 1.7
checksrc17 -source 7 -target 7
+checksrc18
+checksrc18 -target 1.8
+checksrc18 -target 8
+checksrc18 -source 1.8
+checksrc18 -source 8
+checksrc18 -source 1.8 -target 1.8
+checksrc18 -source 8 -target 8
+
fail -source 1.5 -target 1.4 $TC/X.java
fail -source 1.6 -target 1.4 $TC/X.java
fail -source 6 -target 1.4 $TC/X.java
fail -source 1.6 -target 1.5 $TC/X.java
fail -source 6 -target 1.5 $TC/X.java
+fail -source 7 -target 1.6 $TC/X.java
+fail -source 8 -target 1.6 $TC/X.java
+fail -source 8 -target 1.7 $TC/X.java