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

use --release flag of recent java versions #898

Closed
soloturn opened this issue Feb 3, 2022 · 2 comments · Fixed by #899
Closed

use --release flag of recent java versions #898

soloturn opened this issue Feb 3, 2022 · 2 comments · Fixed by #899

Comments

@soloturn
Copy link
Contributor

soloturn commented Feb 3, 2022

since java9 java supports a release flag for building to make sure the code is not using newer APIs. this is supported in maven and gradle:

using this flag revealed two challenges:

  • javac -target -source flags are not good enough guarantee compatiblity with old versions. use --release instead.
  • plantuml uses java.time, introduced in java8. it was built always for java7 and the tools did not notice that installing and using real java7 gives compile and runtime errors.

would be cool if this does not happen any more in future.

@soloturn
Copy link
Contributor Author

soloturn commented Feb 3, 2022

compiling with java17, gradle, setting release to java7 fails immediate, the source code currently needs java8:

> Task :compileJava
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/srv/http/repos/plantuml/src/net/sourceforge/plantuml/project/time/Month.java:38: error: package java.time.format does not exist
import java.time.format.TextStyle;
                       ^
/srv/http/repos/plantuml/src/net/sourceforge/plantuml/project/time/DayOfWeek.java:39: error: package java.time.format does not exist
import java.time.format.TextStyle;
                       ^
/srv/http/repos/plantuml/src/net/sourceforge/plantuml/project/time/Month.java:61: error: package java.time does not exist
        private java.time.Month getJavaTimeMonth() {
                         ^

soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
javac since java9 has a new flat --release to build a binary which can be run
with an older java. the public API of that older release must be followed as
well.

the flags used before, -source, -target do not do this. therefor it got
unnoticed that plantuml did not compile and run in java7 any more, despite
beeing compiled for for java7.

plantuml#898
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
@soloturn
Copy link
Contributor Author

soloturn commented Feb 4, 2022

i installed java7, and it really fails. now i see what the --release flag is for. it effectively gives the same errors without bothering to really install the old java version. a cool flag, i like it.

soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
javac since java9 has a new flat --release to build a binary which can be run
with an older java. the public API of that older release must be followed as
well.

the flags used before, -source, -target do not do this. therefor it got
unnoticed that plantuml did not compile and run in java7 any more, despite
beeing compiled for for java7.

plantuml#898
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 4, 2022
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 5, 2022
javac since java9 has a new flat --release to build a binary which can be run
with an older java. the public API of that older release must be followed as
well.

the flags used before, -source, -target do not do this. therefor it got
unnoticed that plantuml did not compile and run in java7 any more, despite
beeing compiled for for java7.

plantuml#898
soloturn added a commit to soloturn/plantuml that referenced this issue Feb 5, 2022
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 a pull request may close this issue.

1 participant