4 Replies Latest reply on Dec 21, 2004 2:33 PM by ben.wang

    javassist handling of "unused" import package name

      Bill,

      We have discussed this issue before and last week I was at a customer site running into the same problem when using JBossAop. I thought it'd better to discuss it here.

      The problem is that when running aopc, for example, Javassist will try to examine every class on the import declaration. If it can't find the class somewhere, it throws an exception.

      However,

      1. The error message is not verbose enough. Or rather it is cluttered with too many stack traces.

      2. import of a package name not used in the code is actually permitted during javac.

      So what's the solution to this? I am thinking can JBossAop have an aopc flag or something to permit this scenario without throwing exception and stop? That way, when the library path for javac and aopc are different, they don't have to scratch their heads to resolve it.

      Of course, improve the error message can also go a long way. :-)

      Thanks,

      -Ben

        • 1. Re:  javassist handling of "unused" import package name
          starksm64

          Import of an unused class will not compile under javac either. We just need to be providing the same clear indication of the problematic import:

          [starksm@banshee9100 tmp]$ cat X.java
          import nopkg.NoClass;
          
          class X
          {
          }
          
          [starksm@banshee9100 tmp]$ javac X.java
          X.java:1: package nopkg does not exist
          import nopkg.NoClass;
           ^
          1 error
          




          • 2. Re: javassist handling of

            I know that, and that's the reason I am saying that different classpaths for javac and aopc (or even runtime).

            Sometimes during compilation, you knowingly (or unknowingly) include some classpath that you are not using in one specific runtime. So during runtime, you don't include that specific library in the classpath. And everything will be fine since the code is not used.

            But this is not fine under Javassist since it requires access to every import package.

            -Ben

            • 3. Re: javassist handling of
              starksm64

              So what is source of the unused class references, javac putting them into the class file? Create an issue in jira with an example of what your talking about needing to be handled better.

              • 4. Re: javassist handling of