Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 148260

Summary: Update site project builds ignore project specific Java compliance levels.
Product: [Eclipse Project] PDE Reporter: Gary Mohr <Gary.Mohr>
Component: BuildAssignee: pde-build-inbox <pde-build-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: michael.giroux, mober.at+eclipse, pombredanne
Version: 3.1.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Sample project that shows project-local compliance and incorrect generated build.xml none

Description Gary Mohr CLA 2006-06-22 13:46:45 EDT
I have a workspace that has the Java compliance level set to 5.0.  Within this workspace are some plug-in projects that have set a project specific Java compliance level of 1.4 (these projects need to be able to run with either JDK).

This workspace also contains a feature project and an Eclipse update site project.

The Eclipse update site project creates the feature and plug-in jar files which are exported to a .tgz file.  The .tgz file is then installed into Eclipse 3.1.2/WTP 1.0.2 so the plug-ins can be used.

If the Eclipse where this has been installed is run with a JDK 1.5 -vm command line argument all works fine.  

If the Eclipse where this has been installed is run with a JDK 1.4 -vm command line argument, I get the following stack errors when trying to invoke the plug-in:

!SESSION 2006-06-22 10:01:42.412 -----------------------------------------------
eclipse.buildId=M20060118-1600
java.version=1.4.2_11
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86 -clean

!ENTRY org.eclipse.osgi 2006-06-22 10:03:11.240
!MESSAGE An error occurred while automatically activating bundle org.objectweb.jonas.wtp.adapter (346).
!STACK 0
org.osgi.framework.BundleException: The activator org.objectweb.jonas.wtp.adapter.JonasWtpAdapterPlugin for bundle org.objectweb.jonas.wtp.adapter is invalid
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:149)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:965)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:316)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:264)
	at org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:116)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:337)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:389)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:350)
	at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:78)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(BundleLoader.java:275)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:227)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1248)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:152)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:142)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:129)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:48)
	at org.eclipse.wst.server.core.internal.ServerType.createServerDelegate(ServerType.java:83)
	at org.eclipse.wst.server.core.internal.ServerWorkingCopy.getWorkingCopyDelegate(ServerWorkingCopy.java:258)
	at org.eclipse.wst.server.core.internal.ServerWorkingCopy.setDefaults(ServerWorkingCopy.java:503)
	at org.eclipse.wst.server.core.internal.ServerType.createServer(ServerType.java:192)
	at org.eclipse.wst.server.ui.internal.wizard.page.ElementCreationCache.getServer(ElementCreationCache.java:73)
	at org.eclipse.wst.server.ui.internal.wizard.page.NewManualServerComposite$4.run(NewManualServerComposite.java:217)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
Caused by: java.lang.UnsupportedClassVersionError: org/objectweb/jonas/wtp/adapter/JonasWtpAdapterPlugin (Unsupported major.minor version 49.0)
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
	at org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.defineClass(DefaultClassLoader.java:370)
	at org.eclipse.core.runtime.adaptor.EclipseClassLoader.defineClass(EclipseClassLoader.java:233)
	at org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.findClassImpl(DefaultClassLoader.java:343)
	at org.eclipse.osgi.framework.adaptor.core.DefaultClassLoader.findClass(DefaultClassLoader.java:235)
	at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.findLocalClass(AbstractClassLoader.java:183)
	at org.eclipse.core.runtime.adaptor.EclipseClassLoader.basicFindLocalClass(EclipseClassLoader.java:141)
	at org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:82)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:337)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:389)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:350)
	at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:78)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
	at org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(BundleLoader.java:275)
	at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:227)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:142)
	... 23 more
Root exception:
java.lang.UnsupportedClassVersionError: org/objectweb/jonas/wtp/adapter/JonasWtpAdapterPlugin (Unsupported major.minor version 49.0)
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:539)


... (and lots more)


If I change the workspace Java compliance level to 1.4 then when I build and install the plug-ins they work correctly with both JDK's.
Comment 1 Michael Giroux CLA 2006-08-03 16:37:10 EDT
I'm using Eclipse 3.2 and have a similar problem.

The java compliance for the workspace is set to 1.5.
The compliance for my plugin project is set to 1.4.

If I do a clean on the project, then check the class files in /bin, all are compiled w/ 1.4 compliance.

If I launch the plugin using pde launch, the classes on the plugin classpath are indeed 1.4 compliance (since they come from /bin)

However, if I export the plugin using the export wizard the class files that are packed into the library.jar for the plugin are 1.5.  As a result, the plugin classes cannot be loaded w/ jdk 1.4.  It appears that when the plugin is exported, the export wizard uses the global workspace settings, and ignores the project settings.

I tried using the new 3.2 manifest directive:
Bundle-RequiredExecutionEnvironment: J2SE-1.4

but this caused a problem when loading the plugin in Eclipse 3.1.

Comment 2 Martin Oberhuber CLA 2006-08-11 14:02:27 EDT
Created attachment 47786 [details]
Sample project that shows project-local compliance and incorrect generated build.xml

I guess I have the same problem. Using Eclipse 3.2.

I'm using the default compliance settings in my workspace.
I have one plugin with project-specific options set to 1.4.
Locally, everything builds fine.
But the nightly builds, which are done using PDE build / ant, cannot compile the class files (they don't understand the "assert" keyword).

To test this, I selected the "Manifest.mf" file and chose "PDE Tools > Generate ant build file". In the generated build.xml file, I see compliance settings
	<property name="javacSource" value="1.3"/>
	<property name="javacTarget" value="1.2"/>

I'm setting severity to "major" since I do not understand how I could make my nightly builds eat the assert keyword properly.

Find attached my project, including the proper .settings directory and the incorrect generated build.xml file.
Comment 3 Martin Oberhuber CLA 2006-08-11 14:13:28 EDT
Hmm... Just noticed that this is probably a duplicate of bug 134855.

There, it's explained that the headless build has no access to the project properties (and update site builds are headless).

But the headless build should evaluate the Bundle-RequiredExecutionEnvironment setting from Manifest.mf, which I have set correctly. So IMHO, there are two possibilities for a bug:

1) It's by design that headless build cannot evaluate Manifest.mf properly and 
   only looks at build.properties. Then, I'd expect the UI where I set the
   properties to automatically update the build.properties file. Note that I
   have made all changes through the UI only.

2) Headless build should be able to evaluate Manifest.mf. The JVM that I'm
   building on is IBM-5.0, and my RequiredExecutionEnvironment is J2SE-1.4.
   Perhaps the headless build didn't put the settings right because there 
   was no exact match?

I'd appreciate if someone from the PDE build team could look at my attachment and come up with an explanation.
Comment 4 Andrew Niefer CLA 2006-08-14 12:12:18 EDT
By default J2SE-1.4 maps to 1.3/1.2 for source/target levels.  To override this for assert, set the properties javacSource=1.4 and javacTarget=1.4 in your bundle's build.properties file.

The headless build does evaluate the Bundle-RequiredExecutionEnvironment header.  I have noticed occasionally that this doesn't work for some reason, I have raised bug 153778 to figure this out.

When setting the execution environment, you should expect your build.xml to contain something like the following:
	<condition property="bundleBootClasspath" value="${J2SE-1.4}">
		<isset property="J2SE-1.4"/>
	</condition>
	<condition property="bundleJavacSource" value="1.3">
		<isset property="J2SE-1.4"/>
	</condition>
	<condition property="bundleJavacTarget" value="1.2">
		<isset property="J2SE-1.4"/>
	</condition>
At build time, the property J2SE-1.4 is checked.  When using the UI, this property should be automatically set based on your preferences (See Java->installed JREs->Execution Environments).   In a headless setup, this property is expect to be set in the builder configuration build.properties.

See 

Comment 5 Andrew Niefer CLA 2006-08-16 14:41:53 EDT
Marking as a duplicate.  This may initially have been a setup issue, which my previous comment addresses.  See also http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tasks/pde_compilation_env.htm

There is a case where there is an actual bug, which is 153778

*** This bug has been marked as a duplicate of 153778 ***
Comment 6 Martin Oberhuber CLA 2006-08-17 05:32:38 EDT
(In reply to comment #5)
> Marking as a duplicate.  This may initially have been a setup issue, which my
> previous comment addresses.

My point is, that when I edit project-specific preferences in the JDT GUI, and change the compiler compliance settings to 1.4-with-assert, I'd expect the build.properties file to be updated automatically. Otherwise it's just too easy to break the headless (or update site) build with something that seems to work fine (as long as no headless build is done).

Perhaps that would be worth a separate enhancement request?
Comment 7 Andrew Niefer CLA 2006-08-17 10:32:27 EDT
Yes please.  That kind of enhancement would be on PDE/UI.
Comment 8 Michael Giroux CLA 2006-08-17 10:38:18 EDT
Please reference the Feature Request here so I can vote on it.
Comment 9 Martin Oberhuber CLA 2006-08-17 16:11:29 EDT
Enhancement request created as bug 154292