Changeset 19264 in josm for trunk


Ignore:
Timestamp:
2024-12-02T15:29:07+01:00 (26 hours ago)
Author:
taylor.smock
Message:

Fix #24030: JEP 486 (in Java 24) always throws an UnsupportedOperationException 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r19177 r19264  
    787787        I18n.set(language.orElse(null));
    788788
    789         try {
    790             Policy.setPolicy(new Policy() {
    791                 // Permissions for plug-ins loaded when josm is started via webstart
    792                 private final PermissionCollection pc;
    793 
    794                 {
    795                     pc = new Permissions();
    796                     pc.add(new AllPermission());
    797                 }
    798 
    799                 @Override
    800                 public PermissionCollection getPermissions(CodeSource codesource) {
    801                     return pc;
    802                 }
    803             });
    804         } catch (SecurityException e) {
    805             Logging.log(Logging.LEVEL_ERROR, "Unable to set permissions", e);
     789        // JEP 486 (Java 24) now causes exceptions to be thrown. The security manager is terminally deprecated.
     790        if (Utils.getJavaVersion() < 24) {
     791            try {
     792                Policy.setPolicy(new Policy() {
     793                    // Permissions for plug-ins loaded when josm is started via webstart
     794                    private final PermissionCollection pc;
     795
     796                    {
     797                        pc = new Permissions();
     798                        pc.add(new AllPermission());
     799                    }
     800
     801                    @Override
     802                    public PermissionCollection getPermissions(CodeSource codesource) {
     803                        return pc;
     804                    }
     805                });
     806            } catch (SecurityException e) {
     807                Logging.log(Logging.LEVEL_ERROR, "Unable to set permissions", e);
     808            }
    806809        }
    807810
Note: See TracChangeset for help on using the changeset viewer.