Skip to content

Commit

Permalink
WELD-2402 use default proxy package for signed classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tremes authored and mkouba committed Jul 24, 2017
1 parent 5848265 commit 93326db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 18 additions & 2 deletions impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
Expand Up @@ -121,6 +121,8 @@ public class ProxyFactory<T> implements PrivilegedAction<T> {
protected static final String INIT_METHOD_NAME = "<init>";
protected static final String METHOD_HANDLER_FIELD_NAME = "methodHandler";
static final String JAVA = "java";
static final String NULL = "the class package is null";
static final String SIGNED = "the class is signed";

private static final Set<ProxiedMethodFilter> METHOD_FILTERS;

Expand Down Expand Up @@ -232,15 +234,19 @@ static String getProxyName(String contextId, Class<?> proxiedBeanType, Set<? ext
if (superInterface == null) {
throw new IllegalArgumentException("Proxied bean type cannot be java.lang.Object without an interface");
} else {
if (superInterface.getPackage() == null) {
String reason = getDefaultPackageReason(superInterface);
if (reason != null) {
proxyPackage = DEFAULT_PROXY_PACKAGE;
BeanLogger.LOG.generatingProxyToDefaultPackage(superInterface, DEFAULT_PROXY_PACKAGE, reason);
} else {
proxyPackage = superInterface.getPackage().getName();
}
}
} else {
if (proxiedBeanType.getPackage() == null) {
String reason = getDefaultPackageReason(proxiedBeanType);
if (reason != null) {
proxyPackage = DEFAULT_PROXY_PACKAGE;
BeanLogger.LOG.generatingProxyToDefaultPackage(proxiedBeanType, DEFAULT_PROXY_PACKAGE, reason);
} else {
proxyPackage = proxiedBeanType.getPackage().getName();
}
Expand Down Expand Up @@ -940,4 +946,14 @@ protected void getMethodHandlerField(ClassFile file, CodeAttribute b) {
private Class<?> getProxySuperclass() {
return getBeanType().isInterface() ? Object.class : getBeanType();
}

private static String getDefaultPackageReason(Class<?> clazz) {
if (clazz.getPackage() == null) {
return NULL;
}
if (clazz.getSigners() != null) {
return SIGNED;
}
return null;
}
}
6 changes: 5 additions & 1 deletion impl/src/main/java/org/jboss/weld/logging/BeanLogger.java
Expand Up @@ -499,4 +499,8 @@ public interface BeanLogger extends WeldLogger {
@Message(id = 1568, value = "Unable to create ClassFile for: {1}.", format = Format.MESSAGE_FORMAT)
IllegalStateException unableToCreateClassFile(Object name, @Cause Throwable cause);

}
@LogMessage(level = Level.INFO)
@Message(id = 1571, value = "Proxy for {0} created in {1} because {2}.", format = Format.MESSAGE_FORMAT)
void generatingProxyToDefaultPackage(Object param1, Object param2, Object param3);

}

0 comments on commit 93326db

Please sign in to comment.