No scope info for inner classes compiled with JDK 1.3
Status: Alpha
Brought to you by:
lkuehne
Some of our Unit-Tests are currently failing on JDK
1.3, caused by the following application code:
public class X
{
public static void m()
{
class Z {}; // yes, a class defined inside a method
}
}
On JDK 1.3 this is compiled to a class named X$1$Z, and
our code is trying to load X$1 which doesn't exist. I
didn't find any way to determine the correct outer
class X using BCEL.
Note that this isn't a problem with JDK 1.4, which
generates X$1Z (no second $ sign).
Logged In: YES
user_id=408725
I believe that this same problem can be seen with commons
collections. Clirring v3.1 and v3.2 (HEAD) fails due to an
inner class error:
java -jar clirr-core-0.6-uber.jar -o commons-coll
ections-3.1.jar -n commons-collections-3.2-SNAPSHOT.jar -f
clirr.txt
Unable to complete checks:Unable to locate enclosing class
org.apache.commons.collections.DoubleOrderedMap$1 for nested
class org.apache.commons.collections.DoubleOrderedMap$1$1
I got around the problem by temporarily removing the
offending class from the jar.
(Once again, thanks for clirr!)
Logged In: YES
user_id=172636
We have the same problem using JDK 1.5. In an jar of ours,
we added SwingWorker which contains this:
private final FutureTask<V> task =
new FutureTask<V>( new Callable<V>()
{
public V call() throws Exception
{//NOPMD
return construct();
}
} )
{
protected void done()
{
EventQueue.invokeLater( new Runnable()
{
public void run()
{
finished();
}
} );
}
};
This will compile to a nested class inside a nested class,
something like SwingWorker$1$3. This also gives us the
"Unable to locate enclosing class" error.
Do you have plans to solve this, because currently we cannot
use Clirr with this bug.
regards,
Wim
Logged In: YES
user_id=401384
Wim, being able to reproduce this on Java5 is great news.
In your code, is "task" a field in a toplevel class or is it
part of a SwingWorker? It would be easiest if you could
attach two complete source files (old and new version of
your code), so I can create a testcase more quickly.
FYI, Clirr has been refactored to no longer use BCEL, so
there is hope...
Logged In: YES
user_id=401384
Wim sent me the source code in a private email. I'm unable
to reproduce the "Unable to locate enclosing class" problem
for SwingWorker with Clirr's current CVS development status
(ASM instead of BCEL).
This is to be expected, though, because the I get the
following class files (note that the $3 prefix for the $3$1
thing is an existing class):
SwingWorker$1.class
SwingWorker$2.class
SwingWorker$3$1.class
SwingWorker$3.class
SwingWorker.class
Wim, are you sure your class is named SwingWorker$1$3, not
...$3$1? Which compiler (exact JDK version) are you using?
Logged In: YES
user_id=172636
I'm sure about that, it might be the other way round like
you see it. Could you send me a development build of the
current status? I will then test here.
regards,
Wim
Hello,
We have the same problem on XWiki (using the Maven clirr plugin):
vmassol@xwiki-officeimporter $ mvn clirr:check -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.xwiki.platform:xwiki-core-officeimporter:jar:2.4-SNAPSHOT
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING] The expression ${pom.version} is deprecated. Please use ${project.version} instead. @
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building XWiki Platform - Core - Office Importer 2.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] Missing POM for velocity-tools:velocity-tools:jar:1.4
[INFO]
[INFO] >>> clirr-maven-plugin:2.2.2:check (default-cli) @ xwiki-core-officeimporter >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.0-beta-1:enforce (default) @ xwiki-core-officeimporter ---
[WARNING] This rule is not compatible with the current version of Maven. The rule is not able to perform any checks.
[INFO]
[INFO] --- maven-remote-resources-plugin:1.0-beta-2:process (xwiki-license-resources) @ xwiki-core-officeimporter ---
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO]
[INFO] --- maven-resources-plugin:2.4:resources (default-resources) @ xwiki-core-officeimporter ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ xwiki-core-officeimporter ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< clirr-maven-plugin:2.2.2:check (default-cli) @ xwiki-core-officeimporter <<<
[INFO]
[INFO] --- clirr-maven-plugin:2.2.2:check (default-cli) @ xwiki-core-officeimporter ---
[INFO] Comparing to version: 2.3
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.861s
[INFO] Finished at: Sun Jun 13 09:56:44 CEST 2010
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:clirr-maven-plugin:2.2.2:check (default-cli) on project xwiki-core-officeimporter: Execution default-cli of goal org.codehaus.mojo:clirr-maven-plugin:2.2.2:check failed: Unable to locate enclosing class org.xwiki.officeimporter.openoffice.OpenOfficeManager for nested class org.xwiki.officeimporter.openoffice.OpenOfficeManager$ManagerState -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:clirr-maven-plugin:2.2.2:check (default-cli) on project xwiki-core-officeimporter: Execution default-cli of goal org.codehaus.mojo:clirr-maven-plugin:2.2.2:check failed: Unable to locate enclosing class org.xwiki.officeimporter.openoffice.OpenOfficeManager for nested class org.xwiki.officeimporter.openoffice.OpenOfficeManager$ManagerState
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:149)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:77)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:69)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:82)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:54)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.singleThreadedBuild(DefaultLifecycleExecutor.java:218)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:190)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:246)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:95)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:430)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:160)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.mojo:clirr-maven-plugin:2.2.2:check failed: Unable to locate enclosing class org.xwiki.officeimporter.openoffice.OpenOfficeManager for nested class org.xwiki.officeimporter.openoffice.OpenOfficeManager$ManagerState
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:114)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:133)
... 19 more
Caused by: net.sf.clirr.core.CheckerException: Unable to locate enclosing class org.xwiki.officeimporter.openoffice.OpenOfficeManager for nested class org.xwiki.officeimporter.openoffice.OpenOfficeManager$ManagerState
at net.sf.clirr.core.internal.bcel.BcelScopeHelper.getClassScope(BcelScopeHelper.java:94)
at net.sf.clirr.core.internal.bcel.BcelJavaType.getDeclaredScope(BcelJavaType.java:141)
at net.sf.clirr.core.internal.bcel.BcelJavaType.getEffectiveScope(BcelJavaType.java:145)
at net.sf.clirr.core.internal.checks.ClassScopeCheck.check(ClassScopeCheck.java:72)
at net.sf.clirr.core.Checker.runClassChecks(Checker.java:190)
at net.sf.clirr.core.Checker.reportDiffs(Checker.java:136)
at org.codehaus.mojo.clirr.AbstractClirrMojo.executeClirr(AbstractClirrMojo.java:236)
at org.codehaus.mojo.clirr.AbstractClirrMojo.executeClirr(AbstractClirrMojo.java:182)
at org.codehaus.mojo.clirr.ClirrCheckMojo.execute(ClirrCheckMojo.java:68)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
vmassol@xwiki-officeimporter $
We've had to temporarily exclude this class from the checks for now.
Thanks!
To reproduce the problem is relatively easy:
- check out http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-officeimporter/
- add the xwiki maven remote repo to your settings.xml, as explained here: http://dev.xwiki.org/xwiki/bin/view/Community/Building
Thanks
Forgot to mention that this was with CLIRR maven plugin version 2.2.2 which means clirr-core 0.6
I fixed this bug. The old version didn't consider each class name individually and treated subsequent $ as part of the class name. I'd upload the fix in this issue, but permissions problems prevent me from doing so. So I submitted the patch in a separate issue (3093340):
https://sourceforge.net/tracker/?func=detail&aid=3093340&group_id=89627&atid=590801