diff options
2 files changed, 17 insertions, 6 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java index 25f31c5f12..bbbd7daa5f 100644 --- a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java +++ b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java @@ -59,9 +59,6 @@ public class DestroyProcessor extends BaseJavaClassVisitor { if (type.getDestroyMethod() != null) { throw new DuplicateDestructorException("More than one destructor found on implementation"); } - if (!Modifier.isPublic(method.getModifiers())) { - throw new IllegalDestructorException("Destructor must be a public method. Invalid annotation @Destroy found on "+method); - } type.setDestroyMethod(method); } } diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java b/sca-java-2.x/trunk/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java index b82205863c..b524803062 100644 --- a/sca-java-2.x/trunk/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java +++ b/sca-java-2.x/trunk/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java @@ -83,9 +83,8 @@ public class DestroyProcessorTestCase { Method method = Bar.class.getDeclaredMethod("protectedDestroy"); try { processor.visitMethod(method, type); - fail(); } catch (IllegalDestructorException e) { - // expected + fail(); } } @@ -96,9 +95,20 @@ public class DestroyProcessorTestCase { Method method = Bar.class.getDeclaredMethod("privateDestroy"); try { processor.visitMethod(method, type); + } catch (IllegalDestructorException e) { fail(); + } + } + + @Test + public void testDefaultVisibilityDestroy() throws Exception { + DestroyProcessor processor = new DestroyProcessor(assemblyFactory); + JavaImplementation type = javaImplementationFactory.createJavaImplementation(); + Method method = Bar.class.getDeclaredMethod("defaultVisibilityDestroy"); + try { + processor.visitMethod(method, type); } catch (IllegalDestructorException e) { - // expected + fail(); } } @@ -132,5 +142,9 @@ public class DestroyProcessorTestCase { private void privateDestroy(){ } + @Destroy + void defaultVisibilityDestroy(){ + } + } } |