-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-2744 Change how we create ClassFile instances to avoid instantia…
…ting DefaultClassFactory.INSTANCE
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
impl/src/main/java/org/jboss/weld/bean/proxy/DummyClassFactoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.jboss.weld.bean.proxy; | ||
|
||
import org.jboss.classfilewriter.ClassFactory; | ||
import org.jboss.weld.bean.proxy.util.WeldDefaultProxyServices; | ||
|
||
import java.security.ProtectionDomain; | ||
|
||
/** | ||
* A dummy implementation which has only one purpose - to avoid instantiating {@code DefaultClassFactory.INSTANCE}. | ||
* The sole method in this class is never used as we define classes using different means that further vary | ||
* between in-container (such as WildFly) and SE setups. | ||
* <p> | ||
* See {@link WeldDefaultProxyServices#defineClass(Class, String, byte[], int, int)} for details on how we define | ||
* classes. | ||
*/ | ||
class DummyClassFactoryImpl implements ClassFactory { | ||
|
||
private DummyClassFactoryImpl() { | ||
} | ||
|
||
// final so that there's only one instance that's being referenced from anywhere | ||
static final DummyClassFactoryImpl INSTANCE = new DummyClassFactoryImpl(); | ||
|
||
@Override | ||
public Class<?> defineClass(ClassLoader loader, String name, byte[] b, int off, int len, ProtectionDomain protectionDomain) throws ClassFormatError { | ||
throw new UnsupportedOperationException("DummyClasFactoryImpl should not be used to define classes"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters