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

Supports running on Java Early Access versions #93

Merged
merged 2 commits into from
Aug 3, 2018
Merged

Supports running on Java Early Access versions #93

merged 2 commits into from
Aug 3, 2018

Conversation

jqno
Copy link
Contributor

@jqno jqno commented Aug 3, 2018

I'm trying to run my unit tests on an Early Access version of Java 11 (gotta be prepared 😉), and my ArchUnit test fails while attempting to parse the version string:

java.lang.ExceptionInInitializerError
Caused by: java.lang.NumberFormatException: For input string: "11-ea"

This PR should fix that.

Signed-off-by: Jan Ouwens <jankrijgtgra@gmail.com>
@jqno
Copy link
Contributor Author

jqno commented Aug 3, 2018

(I hope it's ok that I used a secondary e-mail address in the sign-off, I don't like leaving my main one in public places on the internet. I do answer this one.)

…up of numbers at the start of the string, then if matcher.matches(..) Integer.parseInt(..) should at least always work.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
@codecholeric
Copy link
Collaborator

Thanks a lot for your contribution 😃
I've made a little adjustment, by just matching the first group of digits (doing [^.] was obviously a little short-sighted 😉). It's kind of what the method name (parseFirstGroupOfJavaVersion) suggests anyway.
Now at least either the matches and the parseInt should work, or the matches should already fail.
How fast do you need this released? I'm gonna release 0.9.0 within the next 2-3 weeks I think, if this patch is vitally important for you, I would do a minor release this weekend.

@jqno
Copy link
Contributor Author

jqno commented Aug 3, 2018

Thanks for the quick response! The adjustment seems like a good idea. A release in the next 2-3 weeks is totally fine for me.

@codecholeric
Copy link
Collaborator

PS: It's hacky 😉, but as a workaround you could probably wrap the class import into sth. like

try {
    System.setProperty("java.version", "11");
    classFileImporter.import... //
} finally {
    System.setProperty("java.version", oldVersion);
}

@codecholeric codecholeric merged commit 9e8af8c into TNG:master Aug 3, 2018
@codecholeric codecholeric added this to the 0.9.0 milestone Aug 19, 2018
@jqno
Copy link
Contributor Author

jqno commented Aug 30, 2018

I just noticed that the release has taken place. Just wanted to confirm that it does indeed work. Thanks!

(Also: looking forward to seeing your talk at JavaZone ;) )

@codecholeric
Copy link
Collaborator

Glad it works!! Looking forward to giving my talk 😃

codecholeric added a commit that referenced this pull request Feb 21, 2021
Supports running on Java Early Access versions
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