Jump to content
Excelsior Forums
Sign in to follow this  

Anonymous Inner Classes in Mixed Compilation Mode

Recommended Posts

In mixed compilation mode, I have deliberately dropped the log4j jar from the initial compilation phase to determine the cause of a classpath problem I have been experiencing.

This (correctly appreas in the build log)...

List of absent classes:

? org/apache/log4j/Logger

? org/apache/log4j/MDC

? com/ibm/icu/util/Calendar

? org/apache/log4j/helpers/FileWatchdog

My code has an anonymous inner class with the following code...

? ?final static void setup() {

? ? ? ? FileWatchdog propertyMonitor = new FileWatchdog(SERVER_PROPS_FILENAME) {

? ? ? ? ? ? protected void doOnChange() {

? ? ? ? ? ?

? ? ? ? ? ? ? ? configure();

? ? ? ? ? ? }

? ? ? ? };

? ? ? ? propertyMonitor.setDelay(10000);

? ? ? ? propertyMonitor.start();

? ? }

The log therefore contains the following

List of classes with absent superclass or superinterface:

? com/istnet/ivr/server/base/AppSetup$1

superclass org/apache/log4j/helpers/FileWatchdog

I have placed log4j on the classpath (which I have verified with a

System.out.println("Classpath " + System.getProperty("java.class.path"));

I was expecting the MCM to resolve the inner class dependency at runtime but I got this error.

Exception in thread "main" java.lang.NoClassDefFoundError: com.istnet.ivr.server.base.AppSetup$1

? ? ? ? at com.istnet.ivr.server.base.AppSetup.setup(AppSetup.java:60)

? ? ? ? at com.istnet.ivr.server.base.Exe.main(Exe.java:22)

Maybe superclass dependencies must be resolved at compile time. Can someone please advise.

Share this post

Link to post
Share on other sites


The class cannot be compiled if its superclass or superinterface is absent.

So the class com/istnet/ivr/server/base/AppSetup$1 was not compiled statically, as its superclass org/apache/log4j/helpers/FileWatchdog was unknown to the compiler.

During execution, you have included the log4j jar, containing FileWatchdog, but it seems that the class file for AppSetup$1 is missing. By default, only resources are packed from the jars that are compiled. So, to enable dynamic compilation of the AppSetup$1 class, you need to include its class file into the classpath at runtime. It can be done in several ways. The first way is to pack the entire application jar into executable, along with all class files. It can be done on the page Resources in the JET Control Panel (select jar and choose "Pack entire jar/zip file"). The second way is to split application jar into two jars - one that is fully compiled, and another jar that will contain class files, required for dynamic compilation.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this