Bug 579317 - Since 2022-03 M3, it is no longer possible to launch an Ant script with Java 8
Summary: Since 2022-03 M3, it is no longer possible to launch an Ant script with Java 8
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 4.23   Edit
Hardware: PC Windows 10
: P3 normal with 3 votes (vote)
Target Milestone: 4.24 M1   Edit
Assignee: Sarika Sinha CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 578843 579515 579540 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-03-18 07:02 EDT by Holger Kanwischer CLA
Modified: 2022-10-11 10:12 EDT (History)
19 users (show)

See Also:


Attachments
screenshot for the event details from the error log (33.40 KB, image/png)
2022-03-18 07:02 EDT, Holger Kanwischer CLA
no flags Details
Ant test script (189 bytes, text/xml)
2022-03-18 07:25 EDT, Holger Kanwischer CLA
no flags Details
Eclipse IDE configuration (79.47 KB, text/plain)
2022-03-18 07:34 EDT, Holger Kanwischer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Holger Kanwischer CLA 2022-03-18 07:02:52 EDT
Created attachment 288242 [details]
screenshot for the event details from the error log

Since 2022-03 M3, it is no longer possible to launch an Ant script.
With M2 in the same workspace it works without problems.

With M3 and the release version a window with the following message appears when launching:
"A JNI error has occurred, please check your installation"

See the attached screenshot for the event details from the error log.
Comment 1 Sarika Sinha CLA 2022-03-18 07:11:10 EDT
Can you attach a sample Ant script? 
Do you have Eclipse SDK or other plugins as well?
Comment 2 Thomas Wolf CLA 2022-03-18 07:25:32 EDT
See also bug 578843.
Comment 3 Holger Kanwischer CLA 2022-03-18 07:25:44 EDT
Created attachment 288243 [details]
Ant test script
Comment 4 Holger Kanwischer CLA 2022-03-18 07:34:49 EDT
Created attachment 288244 [details]
Eclipse IDE configuration
Comment 5 Holger Kanwischer CLA 2022-03-18 07:36:00 EDT
I have added two attachments with an Ant script and my Eclipse IDE configuration.
Comment 6 Jonathan Meier CLA 2022-03-18 12:46:29 EDT
It seems that Ant tasks can no longer be run on Java versions older than 11 starting from Eclipse 2022-03 (4.23). I believe this is caused by Bug 572083.

Also see my comment on Bug 578843 for some more details: https://bugs.eclipse.org/bugs/show_bug.cgi?id=578843#c6
Comment 7 Jonathan Meier CLA 2022-03-18 13:19:37 EDT
Correction: Bug 578533 is likely the cause as the change for the bug I referred to above went into 2021-06 and this issue only started to appear in 2022-03.
Comment 8 Andrey Loskutov CLA 2022-03-18 16:21:48 EDT
Sarika, I wonder if Ant launch config should always try to use Java 11+ runtime if it now requires 11 JVM.
Comment 9 Sarika Sinha CLA 2022-03-21 02:03:20 EDT
(In reply to Andrey Loskutov from comment #8)
> Sarika, I wonder if Ant launch config should always try to use Java 11+
> runtime if it now requires 11 JVM.

Yes, we need to do something on this. Will check.
Comment 10 Rolf Theunissen CLA 2022-03-22 04:10:34 EDT
*** Bug 578843 has been marked as a duplicate of this bug. ***
Comment 11 Mattias Isegran Bergander CLA 2022-03-23 11:03:18 EDT
(In reply to Andrey Loskutov from comment #8)
> Sarika, I wonder if Ant launch config should always try to use Java 11+
> runtime if it now requires 11 JVM.

No I would suggest changing the compiler source/target/release to 8 instead of 11 which was chosen in the linked likely cause issue, as ant is only requiring 1.8 itself.
Comment 12 Andrey Loskutov CLA 2022-03-23 11:06:10 EDT
(In reply to Mattias Isegran Bergander from comment #11)
> (In reply to Andrey Loskutov from comment #8)
> > Sarika, I wonder if Ant launch config should always try to use Java 11+
> > runtime if it now requires 11 JVM.
> 
> No I would suggest changing the compiler source/target/release to 8 instead
> of 11 which was chosen in the linked likely cause issue, as ant is only
> requiring 1.8 itself.

No, that was changed on purpose, because of SecurityManager & co in Java 18+, see bug 575210.
Comment 13 ForceRs CLA 2022-03-24 10:27:52 EDT
I have the same problem.  Mine won't run with Java 11, either.  I don't get the JNI error message, but it pretends to run and ends quickly with zero output. 
As a workaround, I set up a simple batch program that accepts the build target name and runs ant. 

Here's the batch file that should be in placed in the same directory as your build.xml file.  I named mine RunAntTarget.bat: 
cd C:\location\of\build.xml
C:\path\to\apache-ant-n.n.n\bin\ant %1

To use the batch file, create a new External Tool Configuration in the Program section.  Give it the name of the target name you intend to run.  Set the Location to your RunAntTarget.bat file and add the target name (casing matters) to the Arguments section.  To run it, click Run.  After running once, it should appear in the External Tool Configuration pull-down. 

Add as many new External Tool Configurations, one per target you need to run, until this issue is resolved.
Comment 14 Sarika Sinha CLA 2022-03-30 00:51:07 EDT
Previously we had check for Java 8, now changed it to Java 11.
https://github.com/eclipse-platform/eclipse.platform/pull/6
Comment 15 Sascha Broich CLA 2022-03-30 04:00:59 EDT
Just to clarify: Now it's no longer possible to run Ant with Java 8 from within Eclipse?
That should be a big sticker on the package!
Comment 16 Holger Kanwischer CLA 2022-03-30 04:05:11 EDT
No more Java 8, that's really not good news!
Comment 17 Holger Kanwischer CLA 2022-03-30 05:32:01 EDT
Is this restriction to Java 11 really necessary if Ant is started via a separate JRE?
Comment 18 Rolf Theunissen CLA 2022-03-31 03:05:40 EDT
*** Bug 579515 has been marked as a duplicate of this bug. ***
Comment 19 Sarika Sinha CLA 2022-04-01 06:51:20 EDT
*** Bug 579540 has been marked as a duplicate of this bug. ***
Comment 20 Barrie Treloar CLA 2022-04-03 23:49:34 EDT
This is marked as resolved and fixed but I can't see any comments that indicate what was done.

The closest is that you must use jre 11, which is not possible for those still using jre 8
Comment 21 Ed Merks CLA 2022-04-04 01:10:45 EDT
There this pull request link in the See Also section (in the upper right):

https://github.com/eclipse-platform/eclipse.platform/pull/6

And it links to this commit:

https://github.com/eclipse-platform/eclipse.platform/commit/5a8c086442f44719d0edf8af84b177baee0d8a49
Comment 22 Barrie Treloar CLA 2022-04-04 02:06:47 EDT
So the resolution is to not support Java 8.

From the non-committer comments that is the question that we want clarification on.

Can we get someone to include that in these bug notes please?
Comment 23 Ed Merks CLA 2022-04-04 03:46:54 EDT
(In reply to Barrie Treloar from comment #22)
> So the resolution is to not support Java 8.
> 
> From the non-committer comments that is the question that we want
> clarification on.
> 
> Can we get someone to include that in these bug notes please?

When Sarika said

Previously we had check for Java 8, now changed it to Java 11.
https://github.com/eclipse-platform/eclipse.platform/pull/6

it means

"Previously we explicitly told the user that they can't launch because they need Java 8 or higher so now, because Ant won't launch for Java < 11, we changed the guard and the message to check for that and will produce an error message just like before but now telling the user they need Java 11 or higher."
Comment 24 Mattias Isegran Bergander CLA 2022-04-04 04:02:02 EDT
(In reply to Ed Merks from comment #23)
>  because Ant won't launch for Java < 11

Except that statement is not true, Ant itself is still fine with Java 8.

You can download the latest ant and run it fine with Java 8, just not using the built in ant/ant-launcher in Eclipse 2022-03.
Comment 25 Ed Merks CLA 2022-04-04 04:29:07 EDT
(In reply to Mattias Isegran Bergander from comment #24)
> (In reply to Ed Merks from comment #23)
> >  because Ant won't launch for Java < 11
> 
> Except that statement is not true, Ant itself is still fine with Java 8.
> 
> You can download the latest ant and run it fine with Java 8, just not using
> the built in ant/ant-launcher in Eclipse 2022-03.

I didn't say ant doesn't work for Java 8 anymore, I said it won't launch.  Perhaps there would be a way that it would still launch, but https://bugs.eclipse.org/bugs/show_bug.cgi?id=579317#c12 suggests that there is a good reason...  (I'm just the messenger.)
Comment 26 Sanjay Madhavan CLA 2022-06-08 03:49:34 EDT
Could I add my vote to get a workaround to support launching ANT on JDK 1.8. 

This bug basically as I read it says that there is no plan to support JDK 1.8 Ant builds on recent eclipse builds.
Comment 27 Simon Kre CLA 2022-07-13 04:19:32 EDT
Workaround.

If you need to build a Java 8 project then download Apache Ant and you can configure ant build as a new `program` using downloaded external ant binaries in  `External Tools Configuration`. In the Environment tab, you must also set the JAVA_HOME variable to the Java 8 jdk path.
Comment 28 Philip Hachey CLA 2022-08-08 12:42:04 EDT
Although this bug targets the fix for 4.24, this problem is still not resolved in 2022-06 (4.24).  Specifically, running on Linux:
Version: 2022-06 (4.24.0)
Build id: 20220609-1112

I've resorted to running Ant from a command line for my Java 8 projects.
Comment 29 Barrie Treloar CLA 2022-08-09 06:51:41 EDT
Work Around.

Run Ant as Java 11.

Use Java 8 within the Ant script.
Comment 30 Andreas Roerig CLA 2022-08-18 07:51:29 EDT
(In reply to Barrie Treloar from comment #29)
> Work Around.
> 
> Run Ant as Java 11.
> 
> Use Java 8 within the Ant script.

How would you do that within the Ant script?
Comment 31 Michael Gasche CLA 2022-09-16 11:12:15 EDT
Yeah I would be interested too how you can manage running ANT in eclipse (I am on 2022-09) with Java 11, but then telling the ANT script to compile all in Java 8. Somehow I can't use the --release option in the project java compiler settings either.
Comment 32 Michael Gasche CLA 2022-09-16 11:12:39 EDT
Yeah I would be interested too how you can manage running ANT in eclipse (I am on 2022-09) with Java 11, but then telling the ANT script to compile all in Java 8. Somehow I can't use the --release option in the project java compiler settings either.
Comment 33 Michael Gasche CLA 2022-09-16 11:18:59 EDT
(In reply to Andreas Roerig from comment #30)
> (In reply to Barrie Treloar from comment #29)
> > Work Around.
> > 
> > Run Ant as Java 11.
> > 
> > Use Java 8 within the Ant script.
> 
> How would you do that within the Ant script?

This might work:

<target name="compile" depends="copyresources" >
	    <javac  bootclasspath="${boot.classpath}" 
		    	target="8" 
		    	source="8" 
		    	srcdir="${dir.buildfile}/src/main/java" 
		    	includeantruntime="false" 
		    	destdir="${dir.buildfile}/build/classes" 
		    	includes="**/*" 
		    	excludes="**/*.form" >
	        <classpath refid="classpath.base" />
	    </javac>
	</target>
Comment 34 Philip Hachey CLA 2022-09-16 12:20:22 EDT
It's a problem with Ant's wsimport task as well, not just the javac task.  It would be best if the seemingly arbitrary requirement to run Ant in Java 11+ was removed.