You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/08/20 13:38:35 UTC
[1/2] tomee git commit: jdk 11 compatibility
Repository: tomee
Updated Branches:
refs/heads/tomee-7.0.x e157f6d7c -> e4ba57043
jdk 11 compatibility
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/84f96946
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/84f96946
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/84f96946
Branch: refs/heads/tomee-7.0.x
Commit: 84f9694678403e326f48e504aa5e9145ca7cbe97
Parents: e157f6d
Author: Vicente Rossello <vr...@travelcompositor.com>
Authored: Wed Aug 15 23:55:01 2018 +0200
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Aug 20 14:37:40 2018 +0100
----------------------------------------------------------------------
.../util/proxy/LocalBeanProxyFactory.java | 37 +++++++++++++++++---
1 file changed, 33 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/84f96946/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
index 8a0dd8a..a36f7b8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
@@ -17,6 +17,9 @@
package org.apache.openejb.util.proxy;
+
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
import org.apache.openejb.util.Debug;
import org.apache.xbean.asm6.ClassWriter;
import org.apache.xbean.asm6.Label;
@@ -47,6 +50,8 @@ import java.util.concurrent.locks.ReentrantLock;
public class LocalBeanProxyFactory implements Opcodes {
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, QueryProxy.class);
+
public static final InvocationHandler NON_BUSINESS_HANDLER = new NonBusinessHandler();
private static final String BUSSINESS_HANDLER_NAME = "businessHandler";
@@ -700,7 +705,7 @@ public class LocalBeanProxyFactory implements Opcodes {
// sun.misc.Unsafe
private static final Object unsafe;
- private static final Method defineClass;
+ private static final Method unsafeDefineClass;
private static final Method allocateInstance;
private static final Method putObject;
private static final Method objectFieldOffset;
@@ -774,7 +779,7 @@ public class LocalBeanProxyFactory implements Opcodes {
}
}
});
- defineClass = AccessController.doPrivileged(new PrivilegedAction<Method>() {
+ unsafeDefineClass = AccessController.doPrivileged(new PrivilegedAction<Method>() {
@Override
public Method run() {
try {
@@ -782,7 +787,8 @@ public class LocalBeanProxyFactory implements Opcodes {
mtd.setAccessible(true);
return mtd;
} catch (final Exception e) {
- throw new IllegalStateException("Cannot get sun.misc.Unsafe.defineClass", e);
+ LOGGER.debug("Unsafe's defineClass not available, will use classloader's defineClass");
+ return null;
}
}
});
@@ -816,8 +822,31 @@ public class LocalBeanProxyFactory implements Opcodes {
// it is super important to pass a classloader as first parameter otherwise if API class is in a "permanent" classloader then it will leak
public static Class defineClass(final ClassLoader loader, final Class<?> clsToProxy, final String proxyName, final byte[] proxyBytes) throws IllegalAccessException, InvocationTargetException {
- return (Class<?>) defineClass.invoke(unsafe, proxyName, proxyBytes, 0, proxyBytes.length, loader, clsToProxy.getProtectionDomain());
+ if (unsafeDefineClass != null) {
+ return (Class<?>) unsafeDefineClass.invoke(unsafe, proxyName, proxyBytes, 0, proxyBytes.length, loader, clsToProxy.getProtectionDomain());
+ } else {
+ return (Class) getClassLoaderDefineClassMethod(loader).invoke(loader, proxyName, proxyBytes, 0, proxyBytes.length, clsToProxy.getProtectionDomain());
+ }
+ }
+
+ private static Method getClassLoaderDefineClassMethod(ClassLoader classLoader) {
+ Class<?> clazz = classLoader.getClass();
+ Method defineClassMethod = null;
+ do {
+ try {
+ defineClassMethod = clazz.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class, ProtectionDomain.class);
+ } catch (NoSuchMethodException e) {
+ // do nothing, we need to search the superclass
+ }
+ clazz = clazz.getSuperclass();
+ } while (defineClassMethod == null && clazz != Object.class);
+
+ if (defineClassMethod != null && !defineClassMethod.isAccessible()) {
+ defineClassMethod.setAccessible(true);
+ }
+ return defineClassMethod;
}
+
}
@Target(ElementType.TYPE)
[2/2] tomee git commit: typo
Posted by jg...@apache.org.
typo
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e4ba5704
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e4ba5704
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e4ba5704
Branch: refs/heads/tomee-7.0.x
Commit: e4ba570435b23a73c3b20f8cb3da4ccf6ee595c6
Parents: 84f9694
Author: Vicente Rossello <vr...@travelcompositor.com>
Authored: Thu Aug 16 00:16:38 2018 +0200
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Aug 20 14:37:49 2018 +0100
----------------------------------------------------------------------
.../java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e4ba5704/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
index a36f7b8..20e9ab9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
@@ -50,7 +50,7 @@ import java.util.concurrent.locks.ReentrantLock;
public class LocalBeanProxyFactory implements Opcodes {
- private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, QueryProxy.class);
+ private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, LocalBeanProxyFactory.class);
public static final InvocationHandler NON_BUSINESS_HANDLER = new NonBusinessHandler();