diff --git a/classpath/avian/Classes.java b/classpath/avian/Classes.java index 552d954988..3db5a067ab 100644 --- a/classpath/avian/Classes.java +++ b/classpath/avian/Classes.java @@ -13,6 +13,13 @@ package avian; import static avian.Stream.read1; import static avian.Stream.read2; +import java.net.URL; +import java.net.MalformedURLException; +import java.security.CodeSource; +import java.security.AllPermission; +import java.security.Permissions; +import java.security.ProtectionDomain; +import java.security.cert.Certificate; import java.lang.reflect.Modifier; import java.lang.reflect.Method; import java.lang.reflect.Field; @@ -513,6 +520,22 @@ public class Classes { public static Method makeMethod(VMMethod m) { return makeMethod(SystemClassLoader.getClass(m.class_), index(m)); } + + public static ProtectionDomain getProtectionDomain(VMClass c) { + CodeSource source = null; + if (c.source != null) { + try { + source = new CodeSource + (new URL(new String(c.source, 0, c.source.length - 1)), + (Certificate[]) null); + } catch (MalformedURLException ignored) { } + } + + Permissions p = new Permissions(); + p.add(new AllPermission()); + + return new ProtectionDomain(source, p); + } public static native Method makeMethod(Class c, int slot); diff --git a/classpath/avian/OpenJDK.java b/classpath/avian/OpenJDK.java deleted file mode 100644 index d9351ce3ad..0000000000 --- a/classpath/avian/OpenJDK.java +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2008-2013, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package avian; - -import java.net.URL; -import java.net.MalformedURLException; -import java.security.CodeSource; -import java.security.AllPermission; -import java.security.Permissions; -import java.security.ProtectionDomain; -import java.security.cert.Certificate; - -public class OpenJDK { - public static ProtectionDomain getProtectionDomain(VMClass c) { - CodeSource source = null; - if (c.source != null) { - try { - source = new CodeSource - (new URL(new String(c.source, 0, c.source.length - 1)), - (Certificate[]) null); - } catch (MalformedURLException ignored) { } - } - - Permissions p = new Permissions(); - p.add(new AllPermission()); - - return new ProtectionDomain(source, p); - } - - private static byte[] replace(int a, int b, byte[] s, int offset, - int length) - { - byte[] array = new byte[length]; - for (int i = 0; i < length; ++i) { - byte c = s[i]; - array[i] = (byte) (c == a ? b : c); - } - return array; - } -} diff --git a/classpath/java/lang/Class.java b/classpath/java/lang/Class.java index 382fd3b469..32ff0b583b 100644 --- a/classpath/java/lang/Class.java +++ b/classpath/java/lang/Class.java @@ -596,8 +596,6 @@ public final class Class implements Type, AnnotatedElement { } public ProtectionDomain getProtectionDomain() { - Permissions p = new Permissions(); - p.add(new AllPermission()); - return new ProtectionDomain(null, p); + return Classes.getProtectionDomain(vmClass); } } diff --git a/makefile b/makefile index c03a64c785..d9217ecc0a 100755 --- a/makefile +++ b/makefile @@ -1356,10 +1356,7 @@ ifneq ($(classpath),avian) $(classpath-src)/avian/VMMethod.java \ $(classpath-src)/avian/avianvmresource/Handler.java - ifneq ($(openjdk),) - classpath-sources := $(classpath-sources) \ - $(classpath-src)/avian/OpenJDK.java - else + ifeq ($(openjdk),) classpath-sources := $(classpath-sources) \ $(classpath-src)/sun/reflect/ConstantPool.java \ $(classpath-src)/java/lang/ReflectiveOperationException.java \ diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index 4478159ef3..e0f1508d2f 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -4092,7 +4092,7 @@ jvmGetProtectionDomain(Thread* t, uintptr_t* arguments) jclass c = reinterpret_cast(arguments[0]); object method = resolveMethod - (t, root(t, Machine::BootLoader), "avian/OpenJDK", "getProtectionDomain", + (t, root(t, Machine::BootLoader), "avian/Classes", "getProtectionDomain", "(Lavian/VMClass;)Ljava/security/ProtectionDomain;"); return reinterpret_cast