/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 6437138 6482554
* @summary JSR 199: Compiler doesn't diagnose crash in user code
* @library ../lib
* @build JavacTestingAbstractProcessor TestClientCodeWrapper
* @run main TestClientCodeWrapper
*/
new TestClientCodeWrapper().run();
}
/**
* Run a series of compilations, each with a different user-provided object
* configured to throw an exception when a specific method is invoked.
* Then, verify the exception is thrown as expected.
*
* Some methods are not invoked from the compiler, and are excluded from the test.
*/
test(m);
}
test(m);
}
test(m);
}
test(m);
}
test(m);
}
test(m);
}
if (errors > 0)
}
/** Get a sorted set of the methods declared on a class. */
}
/** Get a sorted set of the methods declared on a class, excluding
* specified methods by name. */
}
});
}
return methods;
}
/**
* Test a method in a user supplied component, to verify javac's handling
* of any exceptions thrown by that method.
*/
testNum++;
);
try {
getDiagnosticListener(m, pw),
getCompilationUnits(m));
if (isDeclaredIn(m, Processor.class))
if (isDeclaredIn(m, TaskListener.class))
} catch (RuntimeException e) {
if (e.getClass() == RuntimeException.class) {
} else {
}
} else {
error("Unexpected exception: " + e);
}
}
}
/** Get a file manager to use for the test compilation. */
? new UserFileManager(m, defaultFileManager)
}
/** Get a diagnostic listener to use for the test compilation. */
return isDeclaredIn(m, DiagnosticListener.class)
? new UserDiagnosticListener(m, out)
: null;
}
/** Get a set of file objects to use for the test compilation. */
else
return files;
}
/** Get a set of annotation processors to use for the test compilation. */
}
/** Get a task listener to use for the test compilation. */
return new UserTaskListener(m, out);
}
/** Check if two values are .equal, and report an error if not. */
}
/** Report an error. */
errors++;
}
/** Check if a method is declared in any of a set of classes */
if (c == dc) return true;
}
return false;
}
/** Throw an intentional error if the method has a given name. */
}
int testNum;
int errors;
//--------------------------------------------------------------------------
/**
* Processor used to trigger use of methods not normally used by javac.
*/
boolean firstRound = false;
firstRound = true;
}
if (firstRound) {
try {
f4.getNestingKind();
f4.getAccessLevel();
} catch (IOException e) {
throw new UserError(e);
}
}
return true;
}
//--------------------------------------------------------------------------
// <editor-fold defaultstate="collapsed" desc="User classes">
super(msg);
}
super(t);
}
}
super(delegate);
if (isDeclaredIn(m, JavaFileManager.class)) {
fileManagerMethod = m;
fileObjectMethod = m;
} else
assert false;
}
return super.getClassLoader(location);
}
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
}
}
}
}
return super.hasLocation(location);
}
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
}
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException {
}
public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
}
public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException {
}
super.flush();
}
super.close();
}
return super.isSupportedOption(option);
}
if (fileObjectMethod == null)
return fo;
}
if (fo instanceof UserFileObject)
else
return fo;
}
if (fileObjectMethod == null)
return fo;
}
}
if (fo instanceof UserFileObject)
else
return fo;
}
}
super(delegate);
this.method = m;
}
return fileObject;
}
return super.getKind();
}
}
return super.getNestingKind();
}
return super.getAccessLevel();
}
return super.toUri();
}
return super.getName();
}
return super.openInputStream();
}
return super.openOutputStream();
}
return super.openReader(ignoreEncodingErrors);
}
return super.getCharContent(ignoreEncodingErrors);
}
return super.openWriter();
}
public long getLastModified() {
return super.getLastModified();
}
public boolean delete() {
return super.delete();
}
}
assert isDeclaredIn(m, Processor.class);
method = m;
}
return super.getSupportedOptions();
}
return super.getSupportedAnnotationTypes();
}
return super.getSupportedSourceVersion();
}
super.init(processingEnv);
}
return true;
}
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
}
}
assert isDeclaredIn(m, DiagnosticListener.class);
this.method = m;
}
}
}
assert isDeclaredIn(m, TaskListener.class);
this.method = m;
}
}
}
}
// </editor-fold>
}