Well, I thought I got automatic enhancement working in Eclipse
with Java 1.6 and annotation processing enabled, but this does not seem to be true. If I let Eclipse rebuild the project
completely (Project->clean + automatic rebuild) everything seems to
work and my classes are enhanced automatically. If however I make a change to one class in the editor and save it I get the following error message.
Message:
Exception thrown by Java annotation processor
org.datanucleus.enhancer.EnhancerProcessor@1e50ba9
Exception Stack Trace:
java.lang.IllegalArgumentException: Hook previously registered
at java.lang.ApplicationShutdownHooks.add(Unknown Source)
at java.lang.Runtime.addShutdownHook(Unknown Source)
at org.datanucleus.enhancer.EnhancerProcessor.process(EnhancerProcessor.java:136)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:
139)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:110)
at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(Bas
eAnnotationProcessorManager.java:159)
at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotation
s(IdeAnnotationProcessorManager.java:134)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:837)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:3
21)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:134
)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:265)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Session Data:
eclipse.buildId=M20090917-0800
java.version=1.6.0_17
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments: -os win32 -ws win32 -arch x86 -data C:\Dokumente und Einstellungen\Paus\workspace_dbtest
How can this be avoided?
Michael
PS: With the Eclipse plugin I can start the enhancer as often as I like without problems.
1). it impacts on other people using JDK1.6+ who don't care about such features
2). it is, at best, a poor way of using an annotation processor. By this I mean, an annotation processor is there to perform some step pre-compile as a hook. This is not what we need for enhancement which needs a hook post-compile to update the compiled bytecode.
Since Eclipse doesn't allow use of the "processor" compiler argument then there is no prospect that this issue will ever be addressed (and certainly not without anyone offering their time), so closing. Just use the Eclipse plugin, which is more convenient to that environment anyway