--- old/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java 2019-01-31 16:20:54.711206513 +0000 +++ new/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java 2019-01-31 16:20:54.647206258 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -360,6 +360,12 @@ } catch (ServiceConfigurationError sce) { log.error("proc.bad.config.file", sce.getLocalizedMessage()); throw new Abort(sce); + } catch (UnsupportedClassVersionError ucve) { + log.error("proc.cant.load.class", ucve.getLocalizedMessage()); + throw new Abort(ucve); + } catch (ClassFormatError cfe) { + log.error("proc.cant.load.class", cfe.getLocalizedMessage()); + throw new Abort(cfe); } catch (Throwable t) { throw new Abort(t); } --- old/src/share/classes/com/sun/tools/javac/resources/compiler.properties 2019-01-31 16:20:54.983207597 +0000 +++ new/src/share/classes/com/sun/tools/javac/resources/compiler.properties 2019-01-31 16:20:54.915207326 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2019, 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 @@ -869,6 +869,9 @@ compiler.err.proc.bad.config.file=\ Bad service configuration file, or exception thrown while constructing Processor object: {0} +compiler.err.proc.cant.load.class=\ + Could not load processor class file due to ''{0}''. + compiler.err.proc.cant.create.loader=\ Could not create class loader for annotation processors: {0} --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/BadAnnotationProcessor.java 2019-01-31 16:20:55.191208425 +0000 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019, 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 8218152 + * @summary A bad annotation processor class in a + * jar file should fail with an error + * @author Steven Groeger + * + * @modules java.compiler + * jdk.compiler + * @library bad.annotation.processor.jar + * @compile/fail/ref=BadAnnotationProcessor.out -XDrawDiagnostics -cp . BadAnnotationProcessor.java + */ + +import java.util.*; + +public class BadAnnotationProcessor { + public static void main(String [] args) { + System.out.println("Hello, World."); + + } + + public boolean setName(String name) { + return true; + } +} --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/BadAnnotationProcessor.out 2019-01-31 16:20:55.415209318 +0000 @@ -0,0 +1 @@ +- compiler.err.proc.cant.load.class: Incompatible magic value 1214325024 in class file bad/notaclass --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/InvalidVersionAnnotationProcessor.java 2019-01-31 16:20:55.651210259 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019, 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 8218152 + * @summary An annotation processor class built + * on a higher java version which is used + * when compiling a java file which uses the + * annnotations should fail with an error + * @author Steven Groeger + * + * @modules java.compiler + * jdk.compiler + * @library invalid.annotation.processor.jar + * @compile/fail/ref=InvalidVersionAnnotationProcessor.out -XDrawDiagnostics -cp . InvalidVersionAnnotationProcessor.java + */ + +import java.util.*; +import invalid.PrintMe; + +public class InvalidVersionAnnotationProcessor { + public static void main(String [] args) { + System.out.println("Hello, World."); + + } + + @PrintMe + public boolean setName(String name) { + return true; + } +} --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/InvalidVersionAnnotationProcessor.out 2019-01-31 16:20:55.875211151 +0000 @@ -0,0 +1 @@ +InvalidVersionAnnotationProcessor.java:40:15: compiler.err.cant.access: invalid.PrintMe, (compiler.misc.bad.class.file.header: invalid.annotation.processor.jar(invalid/PrintMe.class), (compiler.misc.wrong.version: 57, 0, 52, 0)) --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/InvalidVersionAnnotationProcessorNoTags.java 2019-01-31 16:20:56.107212075 +0000 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019, 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 8218152 + * @summary An annotation processor class built + * on a higher java version which is used + * when compiling a java file should fail + * with an error + * @author Steven Groeger + * + * @modules java.compiler + * jdk.compiler + * @library invalid.annotation.processor.jar + * @compile/fail/ref=InvalidVersionAnnotationProcessorNoTags.out -XDrawDiagnostics -cp . InvalidVersionAnnotationProcessorNoTags.java + */ + +import java.util.*; + +public class InvalidVersionAnnotationProcessorNoTags { + public static void main(String [] args) { + System.out.println("Hello, World."); + + } + + public boolean setName(String name) { + return true; + } +} --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/InvalidVersionAnnotationProcessorNoTags.out 2019-01-31 16:20:56.327212951 +0000 @@ -0,0 +1 @@ +- compiler.err.proc.cant.load.class: invalid/SimpleAnnotationProcessor has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0 --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/MissingAnnotationProcessor.java 2019-01-31 16:20:56.555213860 +0000 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019, 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 8218152 + * @summary An annotation processor class that is + * missing from a specified jar file should + * fail with an error + * @author Steven Groeger + * + * @modules java.compiler + * jdk.compiler + * @library missing.annotation.processor.jar + * @compile/fail/ref=MissingAnnotationProcessor.out -XDrawDiagnostics -cp . MissingAnnotationProcessor.java + */ + +import java.util.*; + +public class MissingAnnotationProcessor { + public static void main(String [] args) { + System.out.println("Hello, World."); + + } + + public boolean setName(String name) { + return true; + } +} --- /dev/null 2018-12-05 14:06:18.143999701 +0000 +++ new/test/tools/javac/annotations/8218152/MissingAnnotationProcessor.out 2019-01-31 16:20:56.783214768 +0000 @@ -0,0 +1 @@ +- compiler.err.proc.bad.config.file: javax.annotation.processing.Processor: Provider missing.missingclass not found