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

Cleanup code base #33

Merged
merged 5 commits into from
Jun 30, 2023
Merged

Cleanup code base #33

merged 5 commits into from
Jun 30, 2023

Conversation

swismer
Copy link
Collaborator

@swismer swismer commented Jun 27, 2023

As announced in the previous PR, I did some cleanups (remove empty classes, separate unit tests from experiments (and remove some of them), remove unused test resources).

Some comments:

  • I had to remove the println(opcode); in AssemblyParser, because it uses some reflection that is not allowed anymore and was rather for debugging purposes.
  • My original plan to build the project with Java 8 as well did not work, because the build requires at least Java 9, so I skipped that. We could think about requiring at least Java 11 to build the project.

@@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [9, 10, 11, 12, 13]
java: [11, 17, 18, 19, 20]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 8 is still getting security updates until 2030 and is used in some companies. We should ideally support it, if possible.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it fail to build with Java 9?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java 8 is still supported for consumers of this library (see https://github.com/kichik/pecoff4j/blob/master/pom.xml#L116), but not for building, because it includes JPMS support (module-info.java), which Java 8 does not understand.
Building with Java 9 would work, but this version is not supported and should not be used anymore. That's why I removed it. My suggestion would be to reflect that in the pom.xml as well, and set the minimal version to build it to Java 11. Again, the output artifact is still compatible with Java 8 (byte code version and JDK API baseline). IMO, that would be "good enough".

If we don't trust the Java compiler checking the JDK compatibility properly, we would have to abandon the multi-release jar approach. We could separate the different Java versions e.g. by using Maven profiles and release multiple artifacts (pecoff4j-0.4.1-jdk8, pecoff4j-0.4.1-jdk11). I'm not sure whether it's worth the effort...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. Would it be possible for us to build on 11 but also test on 8 automatically here? I assume we would need need a separate job and an artifact passed around, but hopefully there is a simpler solution.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be no nice and easy solution for this. https://stackoverflow.com/questions/70541340/setting-up-multi-release-jar-unit-tests provides some insights. I'd suggest to drop the corresponding commit from this PR (as it does not fit the cleanup topic, anyway) and create a dedicated ticket for that issue. OK for you?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate PR is fine. I don't think there is a need to drop it since it wasn't testing on 8 before either, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not being able to build the project with Java 8, but nevertheless wanting to test it with this version makes it very complicated. I therefore decided to add building support for Java 8 again using a dedicated profile. It's not a perfect solution as we are not testing against the multi-release JAR, but the main goal should be to test the code base for Java 8 compatibility (and have confidence that maven and javac work as expected). I hope that you are OK with this pragmatic solution as well...

public class RCEdit {
public static void main(String[] args) throws Exception {
launch(new String[0]);
launch(new String[] { "/I", "test/WinRun4J.exe", "test/eclipse.ico" });
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test to replace this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, this class is only a stub. The printUsage method documents what the authors of WinRun4J planned to achieve and some methods actually load the executable, but do nothing more.
When I discovered this library, I was also disappointed when realizing that it does not hold its promises... ;-)

@kichik kichik merged commit bd493ca into kichik:master Jun 30, 2023
7 checks passed
@swismer swismer deleted the cleanup branch July 3, 2023 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants