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
*** 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 { --- 80,90 ---- 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> { --- 92,111 ---- throw new RuntimeException("Expected UnknownElementException not thrown."); } catch (UnknownElementException uee) { ; // Expected. } ! JavacTestingAbstractProcessor.LatestElementKindVisitor visitorLatest = ! new JavacTestingAbstractProcessor.LatestElementKindVisitor<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> {