test/tools/javac/processing/model/type/InheritedAP.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2012, 2013, 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.
--- 1,7 ----
/*
! * Copyright (c) 2012, 2014, 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.
*** 23,33 ****
/*
* @test
* @bug 8024513
* @library /tools/javac/lib
! * @build InheritedAP
* @compile -cp . -processor InheritedAP -proc:only InheritedAP.java
* @summary NPE in annotation processing
*/
import java.util.*;
import javax.annotation.processing.*;
--- 23,33 ----
/*
* @test
* @bug 8024513
* @library /tools/javac/lib
! * @build JavacTestingAbstractProcessor InheritedAP
* @compile -cp . -processor InheritedAP -proc:only InheritedAP.java
* @summary NPE in annotation processing
*/
import java.util.*;
import javax.annotation.processing.*;
*** 38,49 ****
import static javax.lang.model.type.TypeKind.*;
import static javax.lang.model.SourceVersion.*;
import static javax.lang.model.util.ElementFilter.*;
@SupportedAnnotationTypes("testclass")
! @SupportedSourceVersion(RELEASE_8)
! public class InheritedAP extends AbstractProcessor {
static Types types;
public void init(ProcessingEnvironment penv) {super.init(penv);}
public static Types getTypes() { return types; }
public boolean process(Set<? extends TypeElement> typeElementSet,RoundEnvironment renv) {
--- 38,48 ----
import static javax.lang.model.type.TypeKind.*;
import static javax.lang.model.SourceVersion.*;
import static javax.lang.model.util.ElementFilter.*;
@SupportedAnnotationTypes("testclass")
! public class InheritedAP extends JavacTestingAbstractProcessor {
static Types types;
public void init(ProcessingEnvironment penv) {super.init(penv);}
public static Types getTypes() { return types; }
public boolean process(Set<? extends TypeElement> typeElementSet,RoundEnvironment renv) {
*** 52,94 ****
return true;
}
types=processingEnv.getTypeUtils();
for (TypeElement typeElem: typesIn(renv.getRootElements())) {
if (typeElem.getAnnotation(testclass.class) != null) {
! new ElementScanner( new SimpleTypeMirrorVisitor()).scan(typeElem, null);
}
}
return true ;
}
}
! class SimpleTypeMirrorVisitor extends SimpleTypeVisitor6 <Void, Void> {
protected Void defaultAction(TypeMirror mirror, Void p ) {
try {
System.out.println( "InheritedAP.getTypes().directSupertypes( "+mirror.toString()+" );" );
InheritedAP.getTypes().directSupertypes(mirror);
System.out.println("PASS");
}catch(java.lang.IllegalArgumentException iae) {/*stuff*/ }
return p;
}
}
! class ElementScanner <T extends SimpleTypeVisitor6<Void, Void> >
! extends ElementScanner6<Void, Void> {
! SimpleTypeVisitor6<Void, Void> typeVisitor;
! public ElementScanner(T typeVisitor) { this.typeVisitor=typeVisitor;}
@Override
public Void scan(Element e, Void p) {
if (e instanceof TypeElement ) {
TypeElement te = (TypeElement) e;
te.getSuperclass().accept(typeVisitor,p);
}
return p;
}
-
}
@interface testclass { }
--- 51,92 ----
return true;
}
types=processingEnv.getTypeUtils();
for (TypeElement typeElem: typesIn(renv.getRootElements())) {
if (typeElem.getAnnotation(testclass.class) != null) {
! new LocalElementScanner( new SimpleTypeMirrorVisitor()).scan(typeElem, null);
}
}
return true ;
}
}
! class SimpleTypeMirrorVisitor extends JavacTestingAbstractProcessor.SimpleTypeVisitor<Void, Void> {
protected Void defaultAction(TypeMirror mirror, Void p ) {
try {
System.out.println( "InheritedAP.getTypes().directSupertypes( "+mirror.toString()+" );" );
InheritedAP.getTypes().directSupertypes(mirror);
System.out.println("PASS");
}catch(java.lang.IllegalArgumentException iae) {/*stuff*/ }
return p;
}
}
! class LocalElementScanner <T extends JavacTestingAbstractProcessor.SimpleTypeVisitor<Void, Void> >
! extends JavacTestingAbstractProcessor.ElementScanner<Void, Void> {
! JavacTestingAbstractProcessor.SimpleTypeVisitor<Void, Void> typeVisitor;
! public LocalElementScanner(T typeVisitor) { this.typeVisitor=typeVisitor;}
@Override
public Void scan(Element e, Void p) {
if (e instanceof TypeElement ) {
TypeElement te = (TypeElement) e;
te.getSuperclass().accept(typeVisitor,p);
}
return p;
}
}
@interface testclass { }