|
1 | 1 | /* |
2 | | - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
26 | 26 |
|
27 | 27 | //Checkstyle: allow reflection |
28 | 28 |
|
29 | | -import java.io.File; |
30 | 29 | import java.io.InputStream; |
31 | 30 | import java.io.Serializable; |
32 | 31 | import java.lang.annotation.Annotation; |
|
43 | 42 | import java.lang.reflect.Modifier; |
44 | 43 | import java.lang.reflect.Type; |
45 | 44 | import java.lang.reflect.TypeVariable; |
46 | | -import java.net.MalformedURLException; |
47 | 45 | import java.net.URL; |
48 | 46 | import java.security.CodeSource; |
49 | 47 | import java.security.ProtectionDomain; |
|
58 | 56 | import org.graalvm.compiler.core.common.NumUtil; |
59 | 57 | import org.graalvm.compiler.core.common.SuppressFBWarnings; |
60 | 58 | import org.graalvm.compiler.serviceprovider.JavaVersionUtil; |
| 59 | +import org.graalvm.nativeimage.ImageSingletons; |
61 | 60 | import org.graalvm.nativeimage.Platform; |
62 | 61 | import org.graalvm.nativeimage.Platforms; |
63 | | -import org.graalvm.nativeimage.ProcessProperties; |
64 | 62 | import org.graalvm.nativeimage.c.function.CFunctionPointer; |
| 63 | +import org.graalvm.nativeimage.impl.ProcessPropertiesSupport; |
65 | 64 | import org.graalvm.util.DirectAnnotationAccess; |
66 | 65 |
|
67 | 66 | import com.oracle.svm.core.RuntimeAssertionsSupport; |
@@ -336,16 +335,12 @@ public void setModule(Object module) { |
336 | 335 | java.security.Permissions perms = new java.security.Permissions(); |
337 | 336 | perms.add(SecurityConstants.ALL_PERMISSION); |
338 | 337 | CodeSource cs; |
339 | | - try { |
340 | | - // Try to use executable image's name as code source for the class. |
341 | | - // The file location can be used by Java code to determine its location on disk, similar |
342 | | - // to argv[0]. |
343 | | - cs = new CodeSource(new File(ProcessProperties.getExecutableName()).toURI().toURL(), (Certificate[]) null); |
344 | | - } catch (MalformedURLException ex) { |
345 | | - // This should not really happen; the file is cannonicalized, absolute, so it should |
346 | | - // always have file:// URL. |
347 | | - cs = null; |
348 | | - } |
| 338 | + |
| 339 | + // Try to use executable image's name as code source for the class. |
| 340 | + // The file location can be used by Java code to determine its location on disk, similar |
| 341 | + // to argv[0]. |
| 342 | + cs = new CodeSource(ImageSingletons.lookup(ProcessPropertiesSupport.class).getExecutableURL(), (Certificate[]) null); |
| 343 | + |
349 | 344 | return new java.security.ProtectionDomain(cs, perms); |
350 | 345 | }); |
351 | 346 |
|
|
0 commit comments