use of java.security.ProtectionDomain in project lombok by rzwitserloot.
the class EclipsePatcher method registerPatchScripts.
private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses, boolean ecjOnly, Class<?> launchingContext) {
ScriptManager sm = new ScriptManager();
sm.registerTransformer(instrumentation);
sm.setFilter(new Filter() {
@Override
public boolean shouldTransform(ClassLoader loader, String className, Class<?> classBeingDefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
if (!(loader instanceof URLClassLoader))
return true;
ClassLoader parent = loader.getParent();
if (parent == null)
return true;
return !parent.getClass().getName().startsWith("org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader");
}
});
final boolean forceBaseResourceNames = !"".equals(System.getProperty("shadow.override.lombok", ""));
sm.setTransplantMapper(new TransplantMapper() {
public String mapResourceName(int classFileFormatVersion, String resourceName) {
if (classFileFormatVersion < 50 || forceBaseResourceNames)
return resourceName;
return "Class50/" + resourceName;
}
});
if (!ecjOnly) {
EclipseLoaderPatcher.patchEquinoxLoaders(sm, launchingContext);
patchCatchReparse(sm);
patchIdentifierEndReparse(sm);
patchRetrieveEllipsisStartPosition(sm);
patchRetrieveRightBraceOrSemiColonPosition(sm);
patchSetGeneratedFlag(sm);
patchDomAstReparseIssues(sm);
patchHideGeneratedNodes(sm);
patchPostCompileHookEclipse(sm);
patchFixSourceTypeConverter(sm);
patchDisableLombokForCodeFormatterAndCleanup(sm);
patchListRewriteHandleGeneratedMethods(sm);
patchSyntaxAndOccurrencesHighlighting(sm);
patchSortMembersOperation(sm);
patchExtractInterface(sm);
patchAboutDialog(sm);
patchEclipseDebugPatches(sm);
} else {
patchPostCompileHookEcj(sm);
}
patchAvoidReparsingGeneratedCode(sm);
patchLombokizeAST(sm);
patchEcjTransformers(sm, ecjOnly);
patchExtensionMethod(sm, ecjOnly);
patchRenameField(sm);
if (reloadExistingClasses)
sm.reloadClasses(instrumentation);
}
use of java.security.ProtectionDomain in project pinpoint by naver.
the class TransformUtils method addField.
public static TransformCallback addField(final String fieldAccessorClassName) {
return new TransformCallback() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
target.addField(fieldAccessorClassName);
return target.toBytecode();
}
};
}
use of java.security.ProtectionDomain in project pinpoint by naver.
the class AgentClassLoaderTest method getProjectLibDir.
private String getProjectLibDir() {
// not really necessary, but useful for testing protectionDomain
ProtectionDomain protectionDomain = AgentClassLoader.class.getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource();
URL location = codeSource.getLocation();
logger.debug("lib location:{}", location);
String path = location.getPath();
// file:/D:/nhn_source/pinpoint_project/pinpoint-tomcat-profiler/target/classes/
int dirPath = path.lastIndexOf("target/classes/");
if (dirPath == -1) {
throw new RuntimeException("target/classes/ not found");
}
String projectDir = path.substring(1, dirPath);
return projectDir + "src/test/lib";
}
use of java.security.ProtectionDomain in project pinpoint by naver.
the class ActiveMQClientPlugin method addMessageDispatchChannelEditor.
private void addMessageDispatchChannelEditor() {
TransformCallback messageDispatchChannelTransformer = new TransformCallback() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
// MessageDispatchChannel is an interface (5.4.0+)
if (!target.isInterceptable()) {
return null;
}
final InstrumentMethod enqueue = target.getDeclaredMethod("enqueue", "org.apache.activemq.command.MessageDispatch");
if (enqueue != null) {
enqueue.addInterceptor(ActiveMQClientConstants.ACTIVEMQ_MESSAGE_DISPATCH_CHANNEL_ENQUEUE_INTERCEPTOR_FQCN);
}
final InstrumentMethod dequeue = target.getDeclaredMethod("dequeue", "long");
if (dequeue != null) {
dequeue.addInterceptor(ActiveMQClientConstants.ACTIVEMQ_MESSAGE_DISPATCH_CHANNEL_DEQUEUE_INTERCEPTOR_FQCN);
}
return target.toBytecode();
}
};
transformTemplate.transform(ActiveMQClientConstants.ACTIVEMQ_MESSAGE_DISPATCH_CHANNEL_FQCN, messageDispatchChannelTransformer);
transformTemplate.transform(ActiveMQClientConstants.ACTIVEMQ_MESSAGE_DISPATCH_CHANNEL_FIFO_FQCN, messageDispatchChannelTransformer);
transformTemplate.transform(ActiveMQClientConstants.ACTIVEMQ_MESSAGE_DISPATCH_CHANNEL_SIMPLE_PRIORITY_FQCN, messageDispatchChannelTransformer);
}
use of java.security.ProtectionDomain in project pinpoint by naver.
the class CassandraPlugin method addDefaultPreparedStatementTransformer.
private void addDefaultPreparedStatementTransformer() {
TransformCallback transformer = new TransformCallback() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
if (!target.isInterceptable()) {
return null;
}
target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor");
target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor");
return target.toBytecode();
}
};
transformTemplate.transform("com.datastax.driver.core.DefaultPreparedStatement", transformer);
}
Aggregations