2 Replies Latest reply on Dec 23, 2011 3:35 AM by Guenther Bodlak

    deployment of EJB using Java 7 try-with-resources fails

    Guenther Bodlak Newbie

      I have problems deploying the following stateless ejb to jboss 7.0.2.

      The cause of the problem is the new java 7 try-with-resources statement in combination with a variable declared ouside of the try block.

      The following code does not make sense its just a sample to reproduce the problem.

       

      Is it a good idea to run AS7 with Java 7 or would you suggest using Java 6?

       

       

      @Stateless
      public class VerifyErrorBean {
          /*
          deployment failes with:
      
          Caused by: java.lang.VerifyError: Inconsistent stackmap frames at branch target 129 in method inet.module.is.dao.VerifyErrorBean.doIt()V at offset 52
          at java.lang.Class.getDeclaredFields0(Native Method) [:1.7.0_01]
          at java.lang.Class.privateGetDeclaredFields(Class.java:2308) [:1.7.0_01]
          at java.lang.Class.getDeclaredFields(Class.java:1760) [:1.7.0_01]
          at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
          */
          public void doIt() {
              int result; // without the variable it works ...
              try (OutputStream out1 = new ByteArrayOutputStream();
                   OutputStream out2 = new ByteArrayOutputStream();) {
                  result = 1;
              } catch (IOException e) {
                  throw new RuntimeException("Some Error", e);
              }
              System.out.println("result=" + result);
          }
      }
      

       

      Thanks

      Günther