unclebob / fitnesse

FitNesse -- The Acceptance Test Wiki
fitnesse.org
Other
2.03k stars 713 forks source link

[Question] When fitnesse enables support for Java 17 or Java 21 #1455

Closed rambangaru closed 4 months ago

rambangaru commented 1 year ago

Have you looked at possible resources for answers?

Please check one of the following resources for help. In particular, questions asked on stack overflow.com will get a lot more viewership than an issue here.

If your answer isn't out there, please describe your question

General Description

It would be nice to have fitnesse supports latest version of Java.

What have you tried?

fhoeben commented 11 months ago

What specific issues are you running into with '20231029'?

I have to admit I have not tried the latest versions of Java yet, but that version upgraded the build process to Java 11 and includes its own JavaScript engine. These were the 2 issues I was aware of preventing usage on recent Java versions. So please make specific what still needs to happen.

rambangaru commented 11 months ago

I'm no facing any specific issue; however, my company would prefer to stay on modern frameworks and tools. It is not blocking me today but may be in few years, so I was curious to know the plan.

Voyinno commented 10 months ago

One issue I am currently facing is this error when launching with java 21. "Test system terminated with exception [fitnesse.testsystems.TestExecutionException: java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release]" This error is present when trying to launch with java 18+. Before that, with java 17 for example, it was only a warning: "WARNING: System::setSecurityManager will be removed in a future release" Here is a link to a SO question: https://stackoverflow.com/questions/76394319/which-java-version-does-fitnesse-slim-works-with This error comes from the fact that The Security Manager has been depecreated from java17, it was raising a warning in java 17. But starting from java18, an exception is being raised even though the class is still present. A solution to this is to add -Djava.security.manager=allow to your java command that starts the tests.

MaikHerrmann commented 8 months ago

One issue I am currently facing is this error when launching with java 21. "Test system terminated with exception [fitnesse.testsystems.TestExecutionException: java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release]" This error is present when trying to launch with java 18+. Before that, with java 17 for example, it was only a warning: "WARNING: System::setSecurityManager will be removed in a future release" Here is a link to a SO question: https://stackoverflow.com/questions/76394319/which-java-version-does-fitnesse-slim-works-with This error comes from the fact that The Security Manager has been depecreated from java17, it was raising a warning in java 17. But starting from java18, an exception is being raised even though the class is still present. A solution to this is to add -Djava.security.manager=allow to your java command that starts the tests.

We are facing the same issue and are thinking about migrating to another framework rather than forcing deprecated method calls via command line argument.

fhoeben commented 8 months ago

Technically it is no big change to remove the usage of the security manager, I believe. As far as I'm aware it is only used to prevent Java code invoked in tests (in the System Under Test) to be able to kill the whole test process by doing a System.exit().

Some users may however be relying on this feature, so it would be good if this could be kept (possibly as an opt-in, plugin, thing they could add to their configuration).

Other than that I would be open to merge a PR removing the usage of the security manager. @MaikHerrmann @Voyinno @rambangaru does one of you have some time to look at creating such a PR?

Chengpu0707 commented 5 months ago

I started https://stackoverflow.com/questions/76394319/which-java-version-does-fitnesse-slim-works-with. Now I have to find a solution to it.

For the latest version of fitnesse, I have started an issue https://github.com/unclebob/fitnesse/issues/1509: The latest fitnesse jar cannot start in the latest java.

For the old version, I started fitnesse successfully as: java -Djava.security.manager=allow -jar fitnesse-standalone.jar, but I still cannot start the page, with contains:

!define TEST_SYSTEM {slim} !path fitnesse-standalone.jar !path C:\Users\Cheng\OneDrive\Documents\Proj\VarianceArithemtic\Java\bin\fitnesse

!|SlimVarDbl| |comment| |52-bit |

The SlimVarDbl.class file contains:

// Source code is decompiled from a .class file using FernFlower decompiler. package fitnesse;

class SlimVarDbl { public String comment;

public SlimVarDbl() { } }

The log is the following:

Could not invoke constructor for SlimVarDbl[0]

Test page: | Fitnesse.VarianceArithmetic.VarDblInitiation -- | -- java -cp fitnesse-standalone.jar;C:\Users\Cheng\OneDrive\Documents\Proj\VarianceArithemtic\Java\bin\fitnesse;lib/*.jar;C:\Users\Cheng\OneDrive\Documents\Proj\VarianceArithemtic\Fitnesse\fitnesse-standalone.jar fitnesse.slim.SlimService 1

====

What could be wrong?

Voyinno commented 5 months ago

I think you also have to add -Djava.security.manager=allow to this command

java -cp fitnesse-standalone.jar;C:\Users\Cheng\OneDrive\Documents\Proj\VarianceArithemtic\Java\bin\fitnesse;lib/*.jar;C:\Users\Cheng\OneDrive\Documents\Proj\VarianceArithemtic\Fitnesse\fitnesse-standalone.jar fitnesse.slim.SlimService 1

To do that, just add the following line !define COMMAND_PATTERN {java -Djava.security.manager=allow -cp %p %m} to your file which contains !path fitnesse-standalone.jar

vboulaye commented 4 months ago

Hi, I had the same issue trying to upgrade to jdk21; there is also a System property inside fitnesse to disable the feature the trap System.exit() calls using -Dprevent.system.exit=false or @FitNesseRunner.PreventSystemExit(false) when using the FitnesseRunner I prefer this workaround as I do not call System.exit in my tests.

I also checked on the JDK side but there is apparently no other way to ignore exit calls in recent JDKs (https://bugs.openjdk.org/browse/JDK-8199704)

Until there is a proper way to fix this, I think we could catch the UnsupportedOperationException exception thrown when System.setSecurityManager is called in SystemExitSecurityManager and show an error message explaining how to fix this with -Djava.security.manager or disabling it with -Dprevent.system.exit

Something similar is already done if a SecurityException (an error is logged but the tests keep on running)