From 3841c03c999eb2e44b9169d84ad11f92b72b58b8 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Mon, 25 Mar 2013 10:13:36 +0000 Subject: [PATCH] Fixed classes not have protected domain. --- src/com/esotericsoftware/reflectasm/AccessClassLoader.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/esotericsoftware/reflectasm/AccessClassLoader.java b/src/com/esotericsoftware/reflectasm/AccessClassLoader.java index a29d150..52622b6 100644 --- a/src/com/esotericsoftware/reflectasm/AccessClassLoader.java +++ b/src/com/esotericsoftware/reflectasm/AccessClassLoader.java @@ -2,6 +2,7 @@ package com.esotericsoftware.reflectasm; import java.lang.reflect.Method; +import java.security.ProtectionDomain; import java.util.ArrayList; class AccessClassLoader extends ClassLoader { @@ -46,9 +47,10 @@ class AccessClassLoader extends ClassLoader { try { // Attempt to load the access class in the same loader, which makes protected and default access members accessible. Method method = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] {String.class, byte[].class, int.class, - int.class}); + int.class, ProtectionDomain.class}); method.setAccessible(true); - return (Class)method.invoke(getParent(), new Object[] {name, bytes, Integer.valueOf(0), Integer.valueOf(bytes.length)}); + return (Class)method.invoke(getParent(), new Object[] {name, bytes, Integer.valueOf(0), Integer.valueOf(bytes.length), + getClass().getProtectionDomain()}); } catch (Exception ignored) { } return defineClass(name, bytes, 0, bytes.length);