test/tools/javac/processing/model/element/TestResourceVariable.java

Print this page

        

*** 21,31 **** * questions. */ /* * @test ! * @bug 6911256 6964740 6967842 6961571 * @summary Test that the resource variable kind is appropriately set * @author Joseph D. Darcy * @library ../../../lib * @build JavacTestingAbstractProcessor TestResourceVariable * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java --- 21,31 ---- * questions. */ /* * @test ! * @bug 6911256 6964740 6967842 6961571 7025809 * @summary Test that the resource variable kind is appropriately set * @author Joseph D. Darcy * @library ../../../lib * @build JavacTestingAbstractProcessor TestResourceVariable * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
*** 39,53 **** import javax.lang.model.util.*; import java.util.*; import com.sun.source.tree.*; import com.sun.source.util.*; import static javax.tools.Diagnostic.Kind.*; /** * Using the tree API, retrieve element representations of the ! * resource of an ARM block and verify their kind tags are set ! * appropriately. */ public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable { int resourceVariableCount = 0; public boolean process(Set<? extends TypeElement> annotations, --- 39,54 ---- import javax.lang.model.util.*; import java.util.*; import com.sun.source.tree.*; import com.sun.source.util.*; import static javax.tools.Diagnostic.Kind.*; + import static JavacTestingAbstractProcessor.*; /** * Using the tree API, retrieve element representations of the ! * resource of a try-with-resources statement and verify their kind ! * tags are set appropriately. */ public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable { int resourceVariableCount = 0; public boolean process(Set<? extends TypeElement> annotations,
*** 80,90 **** try(TestResourceVariable trv1 = this; TestResourceVariable trv2 = trv1) {} } /** * Verify that a resource variable modeled as an element behaves ! * as expected under 6 and 7 specific visitors. */ private static void testResourceVariable(Element element) { ElementVisitor visitor6 = new ElementKindVisitor6<Void, Void>() {}; try { --- 81,91 ---- try(TestResourceVariable trv1 = this; TestResourceVariable trv2 = trv1) {} } /** * Verify that a resource variable modeled as an element behaves ! * as expected under 6 and latest specific visitors. */ private static void testResourceVariable(Element element) { ElementVisitor visitor6 = new ElementKindVisitor6<Void, Void>() {}; try {
*** 92,110 **** throw new RuntimeException("Expected UnknownElementException not thrown."); } catch (UnknownElementException uee) { ; // Expected. } ! ElementKindVisitor7 visitor7 = new ElementKindVisitor7<Object, Void>() { @Override public Object visitVariableAsResourceVariable(VariableElement e, Void p) { return e; // a non-null value } }; ! if (visitor7.visit(element) == null) { throw new RuntimeException("Null result of resource variable visitation."); } } class ResourceVariableScanner extends TreeScanner<Void, CompilationUnitTree> { --- 93,112 ---- throw new RuntimeException("Expected UnknownElementException not thrown."); } catch (UnknownElementException uee) { ; // Expected. } ! ElementKindVisitor visitorLatest = ! new ElementKindVisitor<Object, Void>() { @Override public Object visitVariableAsResourceVariable(VariableElement e, Void p) { return e; // a non-null value } }; ! if (visitorLatest.visit(element) == null) { throw new RuntimeException("Null result of resource variable visitation."); } } class ResourceVariableScanner extends TreeScanner<Void, CompilationUnitTree> {