-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
165 additions
and
123 deletions.
There are no files selected for viewing
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
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
63 changes: 63 additions & 0 deletions
63
...ava/org/apache/commons/javaflow/providers/asm4/AbstractResourceTransformationFactory.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,63 @@ | ||
package org.apache.commons.javaflow.providers.asm4; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.commons.javaflow.spi.Cache; | ||
import org.apache.commons.javaflow.spi.ClassMatcher; | ||
import org.apache.commons.javaflow.spi.ClassMatchers; | ||
import org.apache.commons.javaflow.spi.ResourceLoader; | ||
import org.apache.commons.javaflow.spi.ResourceTransformationFactory; | ||
import org.apache.commons.javaflow.spi.ResourceTransformer; | ||
import org.apache.commons.javaflow.spi.VetoableResourceLoader; | ||
|
||
import org.objectweb.asm.ClassReader; | ||
|
||
public abstract class AbstractResourceTransformationFactory implements ResourceTransformationFactory { | ||
|
||
public ResourceTransformer createTransformer(ResourceLoader resourceLoader) { | ||
SharedContinuableClassInfos cciShared = CACHED_SHARED_CCI.get(resourceLoader); | ||
return createTransformer( | ||
resourceLoader, | ||
new IContinuableClassInfoResolver(resourceLoader, cciShared), | ||
// Actualize ClassHierarchy per resource loader | ||
cciShared.hierarchy().shareWith(resourceLoader) | ||
); | ||
} | ||
|
||
abstract protected ResourceTransformer createTransformer(ResourceLoader resourceLoader, | ||
ContinuableClassInfoResolver resolver, | ||
ClassHierarchy classHierarchy); | ||
|
||
public ContinuableClassInfoResolver createResolver(ResourceLoader resourceLoader) { | ||
return new IContinuableClassInfoResolver( | ||
resourceLoader, | ||
CACHED_SHARED_CCI.get(resourceLoader) | ||
); | ||
} | ||
|
||
public String readClassName(byte[] classBytes) { | ||
return new ClassReader(classBytes).getClassName(); | ||
} | ||
|
||
static ClassMatcher createVeto(ResourceLoader resourceLoader) { | ||
if (resourceLoader instanceof VetoableResourceLoader) { | ||
try { | ||
return ((VetoableResourceLoader)resourceLoader).createVeto(); | ||
} catch (IOException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} else { | ||
return ClassMatchers.MATCH_NONE; | ||
} | ||
} | ||
|
||
private static final Cache<ResourceLoader, SharedContinuableClassInfos> CACHED_SHARED_CCI = | ||
new Cache<ResourceLoader, SharedContinuableClassInfos>() { | ||
@Override | ||
protected SharedContinuableClassInfos createValue(ResourceLoader loader) { | ||
return new SharedContinuableClassInfos( | ||
new ClassHierarchy(loader), createVeto(loader) | ||
); | ||
} | ||
}; | ||
} |
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
63 changes: 63 additions & 0 deletions
63
...ava/org/apache/commons/javaflow/providers/asm5/AbstractResourceTransformationFactory.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,63 @@ | ||
package org.apache.commons.javaflow.providers.asm5; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.commons.javaflow.spi.Cache; | ||
import org.apache.commons.javaflow.spi.ClassMatcher; | ||
import org.apache.commons.javaflow.spi.ClassMatchers; | ||
import org.apache.commons.javaflow.spi.ResourceLoader; | ||
import org.apache.commons.javaflow.spi.ResourceTransformationFactory; | ||
import org.apache.commons.javaflow.spi.ResourceTransformer; | ||
import org.apache.commons.javaflow.spi.VetoableResourceLoader; | ||
|
||
import org.objectweb.asm.ClassReader; | ||
|
||
public abstract class AbstractResourceTransformationFactory implements ResourceTransformationFactory { | ||
|
||
public ResourceTransformer createTransformer(ResourceLoader resourceLoader) { | ||
SharedContinuableClassInfos cciShared = CACHED_SHARED_CCI.get(resourceLoader); | ||
return createTransformer( | ||
resourceLoader, | ||
new IContinuableClassInfoResolver(resourceLoader, cciShared), | ||
// Actualize ClassHierarchy per resource loader | ||
cciShared.hierarchy().shareWith(resourceLoader) | ||
); | ||
} | ||
|
||
abstract protected ResourceTransformer createTransformer(ResourceLoader resourceLoader, | ||
ContinuableClassInfoResolver resolver, | ||
ClassHierarchy classHierarchy); | ||
|
||
public ContinuableClassInfoResolver createResolver(ResourceLoader resourceLoader) { | ||
return new IContinuableClassInfoResolver( | ||
resourceLoader, | ||
CACHED_SHARED_CCI.get(resourceLoader) | ||
); | ||
} | ||
|
||
public String readClassName(byte[] classBytes) { | ||
return new ClassReader(classBytes).getClassName(); | ||
} | ||
|
||
static ClassMatcher createVeto(ResourceLoader resourceLoader) { | ||
if (resourceLoader instanceof VetoableResourceLoader) { | ||
try { | ||
return ((VetoableResourceLoader)resourceLoader).createVeto(); | ||
} catch (IOException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} else { | ||
return ClassMatchers.MATCH_NONE; | ||
} | ||
} | ||
|
||
private static final Cache<ResourceLoader, SharedContinuableClassInfos> CACHED_SHARED_CCI = | ||
new Cache<ResourceLoader, SharedContinuableClassInfos>() { | ||
@Override | ||
protected SharedContinuableClassInfos createValue(ResourceLoader loader) { | ||
return new SharedContinuableClassInfos( | ||
new ClassHierarchy(loader), createVeto(loader) | ||
); | ||
} | ||
}; | ||
} |
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
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
Oops, something went wrong.