This is an automated email from the ASF dual-hosted git repository. mbenson pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-weaver.git
commit 232f479747b016d307e214ad5906f82db0c5a58b Author: Matt Benson <mben...@apache.org> AuthorDate: Mon Apr 23 14:30:33 2018 -0500 clone from ClassWriter#getCommonSuperClass --- .../commons/weaver/privilizer/Privilizer.java | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java index ae8036b..5da66bd 100644 --- a/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java +++ b/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java @@ -73,7 +73,7 @@ public class Privilizer { } } - private static final class CustomClassWriter extends ClassWriter { + private final class CustomClassWriter extends ClassWriter { CustomClassWriter(final int flags) { super(flags); } @@ -84,7 +84,34 @@ public class Privilizer { @Override protected String getCommonSuperClass(final String type1, final String type2) { - return "java/lang/Object"; +// https://gitlab.ow2.org/asm/asm/merge_requests/166 + ClassLoader classLoader = env.classLoader; + Class<?> class1; + try { + class1 = Class.forName(type1.replace('/', '.'), false, classLoader); + } catch (Exception e) { + throw new TypeNotPresentException(type1, e); + } + Class<?> class2; + try { + class2 = Class.forName(type2.replace('/', '.'), false, classLoader); + } catch (Exception e) { + throw new TypeNotPresentException(type2, e); + } + if (class1.isAssignableFrom(class2)) { + return type1; + } + if (class2.isAssignableFrom(class1)) { + return type2; + } + if (class1.isInterface() || class2.isInterface()) { + return "java/lang/Object"; + } else { + do { + class1 = class1.getSuperclass(); + } while (!class1.isAssignableFrom(class2)); + return class1.getName().replace('.', '/'); + } } } -- To stop receiving notification emails like this one, please contact mben...@apache.org.