OWB-1152 improve Java9 support


git-svn-id: https://svn.apache.org/repos/asf/openwebbeans/trunk@1759902 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webbeans-el22/pom.xml b/webbeans-el22/pom.xml
index 3bdf878..e2d9b28 100644
--- a/webbeans-el22/pom.xml
+++ b/webbeans-el22/pom.xml
@@ -67,8 +67,14 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-interceptor_1.2_spec</artifactId>
             <scope>provided</scope>
-        </dependency>        
-        
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-annotation_1.2_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java b/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
index 4dd5e35..ef1796a 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
@@ -1216,6 +1216,7 @@
     {
         logger.fine("Deploying configurations from class files has started.");
 
+        BeanManagerImpl bm = webBeansContext.getBeanManagerImpl();
         for (Map<AnnotatedType<?>, ExtendedBeanAttributes<?>> beanAttributesMap : beanAttributesPerBda.values())
         {
 
@@ -1234,7 +1235,7 @@
                 // if the implClass already gets processed as part of the
                 // standard BDA scanning, then we don't need to 'additionally'
                 // deploy it anymore.
-                webBeansContext.getBeanManagerImpl().removeAdditionalAnnotatedType(annotatedType.getKey());
+                bm.removeAdditionalAnnotatedType(annotatedType.getKey());
 
             }
         }
@@ -1273,7 +1274,7 @@
             }
             catch (NoClassDefFoundError ncdfe)
             {
-                logger.info("Skipping deployment of Class " + beanClass + "due to a NoClassDefFoundError: " + ncdfe.getMessage());
+                logger.warning("Skipping deployment of Class " + beanClass + " due to a NoClassDefFoundError: " + ncdfe.getMessage());
             }
         }
     }
diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java b/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
index bc23ded..ff2da25 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
@@ -326,10 +326,9 @@
         {
             return cast(methods);
         }
-        methods = Collections.unmodifiableSet(getFilteredMethods(
-                annotatedType.getJavaClass(),
-                (Set<AnnotatedMethod<?>>)(Set<?>)annotatedType.getMethods(),
-                new HashSet<AnnotatedMethod<?>>()));
+        methods = Collections.unmodifiableSet(getFilteredMethods(annotatedType.getJavaClass(),
+                                                                 (Set)annotatedType.getMethods(),
+                                                                 new HashSet<AnnotatedMethod<?>>()));
         Set<AnnotatedMethod<?>> old = annotatedMethodsOfTypeCache.putIfAbsent(annotatedType, methods);
         if (old != null)
         {
diff --git a/webbeans-tomcat7/src/test/java/org/apache/webbeans/web/tomcat7/test/TomcatNormalScopeProxyFactoryTest.java b/webbeans-tomcat7/src/test/java/org/apache/webbeans/web/tomcat7/test/TomcatNormalScopeProxyFactoryTest.java
index f1c83eb..aeed845 100644
--- a/webbeans-tomcat7/src/test/java/org/apache/webbeans/web/tomcat7/test/TomcatNormalScopeProxyFactoryTest.java
+++ b/webbeans-tomcat7/src/test/java/org/apache/webbeans/web/tomcat7/test/TomcatNormalScopeProxyFactoryTest.java
@@ -21,6 +21,7 @@
 import org.apache.catalina.Context;

 import org.apache.catalina.connector.Request;

 import org.apache.catalina.connector.Response;

+import org.apache.catalina.core.StandardContext;

 import org.apache.catalina.startup.Tomcat;

 import org.apache.tomcat.util.http.fileupload.IOUtils;

 import org.apache.webbeans.config.WebBeansContext;

@@ -41,12 +42,16 @@
 import java.io.OutputStream;

 import java.io.Writer;

 import java.lang.reflect.Method;

+import java.util.logging.Level;

+import java.util.logging.Logger;

 

 import static java.util.Arrays.asList;

 import static org.junit.Assert.assertEquals;

 

 public class TomcatNormalScopeProxyFactoryTest

 {

+    private static final Logger log = Logger.getLogger(TomcatNormalScopeProxyFactoryTest.class.getName());

+

     @Test

     public void checkDeserialisation() throws Exception

     {

@@ -63,6 +68,11 @@
             final Context ctx = tomcat.addContext("/test", war.getAbsolutePath());

             ctx.addLifecycleListener(new ContextLifecycleListener());

 

+            // needed for Java9

+            if (ctx instanceof StandardContext) {

+                ((StandardContext) ctx).setClearReferencesRmiTargets(false);

+            }

+

             tomcat.start();

 

             try

@@ -114,6 +124,9 @@
                     // don't do to not destroy the instance

                     // contextsService.endContext(SessionScoped.class, request.getSession());

                 }

+                catch (Exception e) {

+                    log.log(Level.SEVERE, "Exception during test execution", e);

+                }

                 finally

                 {

                     thread.setContextClassLoader(old);

@@ -121,7 +134,15 @@
             }

             finally

             {

-                tomcat.stop();

+                try

+                {

+                    tomcat.stop();

+                }

+                catch (Exception e)

+                {

+                    log.log(Level.SEVERE, "This _might_ happen on Java9 currently. I hope it gets soon fixed.", e);

+                }

+

             }

         }

     }