Skip to content

Commit

Permalink
Fix #24030: JEP 486 (in Java 24) always throws an UnsupportedOperatio…
Browse files Browse the repository at this point in the history
…nException when attempting to set security policy

This merely fixes startup issues. There are a few other locations which ''may''
cause issues, but did not during relatively minimal testing.

git-svn-id: https://josm.openstreetmap.de/svn/trunk@19264 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Dec 2, 2024
1 parent 2b3bb3e commit 52ac12e
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/org/openstreetmap/josm/gui/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -786,23 +786,26 @@ public static void mainJOSM(ProgramArguments args) {
Optional<String> language = args.getSingle(Option.LANGUAGE);
I18n.set(language.orElse(null));

try {
Policy.setPolicy(new Policy() {
// Permissions for plug-ins loaded when josm is started via webstart
private final PermissionCollection pc;
// JEP 486 (Java 24) now causes exceptions to be thrown. The security manager is terminally deprecated.
if (Utils.getJavaVersion() < 24) {
try {
Policy.setPolicy(new Policy() {
// Permissions for plug-ins loaded when josm is started via webstart
private final PermissionCollection pc;

{
pc = new Permissions();
pc.add(new AllPermission());
}
{
pc = new Permissions();
pc.add(new AllPermission());
}

@Override
public PermissionCollection getPermissions(CodeSource codesource) {
return pc;
}
});
} catch (SecurityException e) {
Logging.log(Logging.LEVEL_ERROR, "Unable to set permissions", e);
@Override
public PermissionCollection getPermissions(CodeSource codesource) {
return pc;
}
});
} catch (SecurityException e) {
Logging.log(Logging.LEVEL_ERROR, "Unable to set permissions", e);
}
}

try {
Expand Down

0 comments on commit 52ac12e

Please sign in to comment.