Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open Java sources if NetBeans 12.6 is run on JDK 8 #178

Closed
jkovalsky opened this issue Jan 4, 2022 · 19 comments
Closed

Cannot open Java sources if NetBeans 12.6 is run on JDK 8 #178

jkovalsky opened this issue Jan 4, 2022 · 19 comments
Assignees
Milestone

Comments

@jkovalsky
Copy link

I tried to install 1.14.2 version of External Java Code Formatters plugin to my Apache NetBeans IDE 12.6 running on JDK 1.8.0 Update 271 but it resulted in unusable Editor. Opening any Java file resulted in empty editor due to attached UCVError.txt. Please see the attached file. Can you please compile the plugin with older JDK?

@jkovalsky
Copy link
Author

Please note that 1.14.0 version of the plugin works fine in Apache NetBeans 11.3 running on JDK 1.8.0 Update 271.

@funfried
Copy link
Owner

funfried commented Jan 4, 2022

Hello @jkovalsky,

I tried to compile against JDK 1.8, but unfortunately I'm using past JDK 1.8 features like Lambdas and Streams and so on in my source code, so I think there is no turning back to Java 1.8 for me here.
Is there any way of not compiling the plugin against JDK 1.8 and still getting the verification somehow?

Kind regards,
Fabian

@funfried
Copy link
Owner

funfried commented Jan 4, 2022

@jkovalsky
I looked a bit deeper into this and actually Lambda and Streams were introduced in Java 1.8, so that's not really the problem. But the latest Eclipse formatter (and maybe others are/)is also compiled with Java 11 and so I cannot compile with Java 1.8 anymore as my dependencies are already compiled with Java 11.

So the question is still: Can I get the verification even when my plugin is compiled with Java 11 or is there no chance?
I think version 1.14.1 was also compiled with Java 11 and I got the verification without any complains 🤷‍♂️

In earlier NetBeans plugin development (with Ant instead of Maven) it was possible to add "Required Tokens" to e.g. exclude plugins from Windows, Linux or macOS or if another plugin is not installed which provides a specific token. Do you know if that's still possible and if there is a token for the JDK version which is used to run NetBeans? So I could hide the plugin from NetBeans instances running below Java 11. Would this be an option?

Also would it be ok for you if I ask in the NetBeans dev mailing list for advice?

Kind regards,
Fabian

@jkovalsky
Copy link
Author

@funfried thanks for your reply and investigation. You can of course ask for help via dev@netbeans.apache.org mailing list but maybe you just want to copy the same solution which is used in the 1.14.0 version of your plugin which works fine also in 12.6. Unfortunately, 1.14.1 version is also broken and makes NetBeans Java Editor unusable.

Until this is sorted out I would recommend requesting verification of 1.14.0 version for NetBeans 12.6 users.

@funfried
Copy link
Owner

funfried commented Jan 5, 2022

Hmm, I think there is a misunderstanding here.
For my understanding: You are saying that my plugin isn't working with NetBeans 12.6 running with Java 1.8, correct?
But I think it is working under NetBeans 12.6 running with Java 11, did you check that as well?

And 1.14.0 is only working because it is using an older version of the Eclipse formatter which was compiled with Java 1.8, but they switched from Java 8 to 11, so I did the same which seemed legit to me as Java 8 is quite old now and Java 11 was the latest LTS release when I was switching. But nevertheless, as said, my latest dependencies (I think not just Eclipse formatter also the Google formatter) are using Java 11 and I cannot stay with older versions as you can imaging.

@jkovalsky
Copy link
Author

Yes, the 1.14.1 plugin works fine in NetBeans 12.6 running on JDK 11 of course. So there are two options:

  1. Either your plugin will disable its functionality if NetBeans is running on JDK 1.8 or
  2. You make it clear in its description both NBM and Plugin Portal that it requires JDK 11 and that on JDK 1.8 editing of Java sources is corrupted.

In both cases I am willing to revisit my NoGo decision and approve it for publishing on the Plugin Portal Update Center.

funfried added a commit that referenced this issue Jan 5, 2022
Added a module installer to the plugin, so NetBeans will try to call the plugin when starting up and fail to call the installer if NetBeans runs below Java 11, otherwise it would cause issues in the editor during runtime when NetBeans is running with Java 8 instead of Java 11 (which is required by this plugin and its dependencies)
@funfried
Copy link
Owner

funfried commented Jan 5, 2022

Thanks! First solution sounds perfect to me, I just found out that a Module Installer shows that the plugin won't work on NetBeans running with Java 8 when the plugin should get activated, so that should be fine I guess.

Unfortunately, Travis is not running my pipelines anymore as I'm using a free plan and it seems I exceeded my free credits there, so I cannot deploy any versions to Maven Central or GitHub at the moment as Travis is usually responsible for that in my release workflow. I have to switch to GitHub Actions for that first and will then come back to you.

Kind regards,
Fabian

@jkovalsky
Copy link
Author

FYI, I have just learned that the preferred way how to do it is much easier. See here.

@funfried
Copy link
Owner

Looks a lot better, thanks! I'll try it and let you know when I have a new version published. It seems I've also migrated my release pipeline to GitHub Actions successfully, so it shouldn't take very long, maybe today evening or tomorrow.

@funfried funfried added this to the 1.14.3 milestone Jan 11, 2022
@funfried funfried self-assigned this Jan 11, 2022
funfried added a commit that referenced this issue Jan 12, 2022
Removed Installer and instead added property in manifest.mf to check Java version is greater than or equal to Java 11
funfried added a commit that referenced this issue Jan 12, 2022
Added issue to changelog
@funfried
Copy link
Owner

Hi @jkovalsky,

Finally I got everything together (better than before) and here is the fixed version as a pre-release: 1.14.3-SNAPSHOT
Could you please be so kind and test that version and tell me if that one would get the verification? If yes, I build the next release based on that, otherwise I can continue to improve the plugin before I build another release.

Thanks in advance.

Cheers,
Fabian

@jkovalsky
Copy link
Author

I am sorry but I cannot access the file. Can you fix it or share the NBM elsewhere?
<Error> <Code>AccessDenied</Code> <Message>Request has expired</Message> <X-Amz-Expires>300</X-Amz-Expires> <Expires>2022-01-12T22:52:38Z</Expires> <ServerTime>2022-01-13T20:03:00Z</ServerTime> <RequestId>BPG0GH0MBTMJNEGY</RequestId> <HostId> IsiqrDe3siMmJLFw8JvLzH6IPef028ASJaWoL8txRTaPQzrnGsvPotGNLZX4FDAb4Yoc+kHg0FU= </HostId> </Error>

@funfried
Copy link
Owner

Hi @jkovalsky,
maybe you can check the Packages for the latest NBM, or here is another direct link again.

I hope it's working this time 🤞

@dgreen
Copy link

dgreen commented Jan 13, 2022

Just a follower, but I was able to download it from Packages (it is about midway down on the list on the right). I can confirm that it worked on JDK17, NB12.6, (MacOSX, M1 Pro, Monterey). Thanks for working through this. I realize the real test is the behavior for JDK 1.8, which I cannot test.

@funfried
Copy link
Owner

@dgreen I need the confirmation for Java 1.8, but thanks for checking as well!

@jkovalsky
Copy link
Author

Thanks for the packages link. Unfortunately, after successful installation of the plugin in Apache NetBeans 12.6 running on 1.8.0_271 I keep getting the following exception and the problem persists. The plugin UI such as External Formatter options category is empty, user cannot open project properties, navigator never loads and Java files complain about missing mime type.

obrazek

@funfried
Copy link
Owner

@jkovalsky That's really weird, as for me there is an error when starting the NetBeans IDE with Java 1.8 (running my project from within NetBeans) that I have to disable the plugin as it won't work with Java 1.8, only with Java 11. I'll do some more research on my system and try to reproduce this issue. Thanks again for trying it out and for the feedback.

@funfried
Copy link
Owner

Hello @jkovalsky,

Finally I had some time to test it myself with Java 1.8 and NetBeans 12.5 and I got this when I tried to install the plugin:

image

I wonder why this message wasn't shown for you as well.

Maybe you've got an old SNAPSHOT by accident, could you please try once more with this NBM file?

Sorry for the whole back and forth, I hope this is solving the issue now.

Cheers,
Fabian

@jkovalsky
Copy link
Author

Hey Fabian, please accept my apologies! Your assumption was right as I downloaded wrong file (externalcodeformatter-1.14.3-20220104.225539-1.nbm). With externalcodeformatter-1.14.3-20220112.231113-6.nbm everything works great and I cannot install your plugin with JDK 1.8 while with JDK 11 it works fine.

You are good to go!

@funfried
Copy link
Owner

Perfect, thanks again for pre-testing! I'm just really happy that it works now.
I'll try to fix #152 as well and then create a final release with both fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants