diff --git a/README.md b/README.md index 511cb89..faeedf4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ JAgent ====== + +[ ![Download](https://api.bintray.com/packages/devexperts/Maven/jagent/images/download.svg) ](https://bintray.com/devexperts/Maven/jagent/_latestVersion) + **JAgent** framework helps you to implement java agents. It has some extra functionality instead of standard Java's API. diff --git a/jagent-api/pom.xml b/jagent-api/pom.xml index 7be07a1..3b6536c 100644 --- a/jagent-api/pom.xml +++ b/jagent-api/pom.xml @@ -3,7 +3,7 @@ jagent com.devexperts.jagent - 1.4-SNAPSHOT + 1.4 4.0.0 diff --git a/jagent-impl/pom.xml b/jagent-impl/pom.xml index 3ec168b..3d323d4 100644 --- a/jagent-impl/pom.xml +++ b/jagent-impl/pom.xml @@ -3,7 +3,7 @@ jagent com.devexperts.jagent - 1.4-SNAPSHOT + 1.4 4.0.0 diff --git a/jagent-impl/src/main/java/com/devexperts/jagent/CachingClassFileTransformer.java b/jagent-impl/src/main/java/com/devexperts/jagent/CachingClassFileTransformer.java index 7bb8ce5..5246ca3 100644 --- a/jagent-impl/src/main/java/com/devexperts/jagent/CachingClassFileTransformer.java +++ b/jagent-impl/src/main/java/com/devexperts/jagent/CachingClassFileTransformer.java @@ -99,8 +99,10 @@ private void dumpClassIfNeeded(String className, ClassLoader loader, byte[] clas if (dumpDir == null) return; try { - Path classPath = Paths.get(dumpDir, className + "#loaderHashCode=" + (loader != null ? loader.hashCode() : null)); - Files.createDirectories(classPath.getParent()); + Path classPath = Paths.get(dumpDir, className + "#loaderHashCode=" + + (loader != null ? loader.hashCode() : null) + ".class"); + if (classPath.getParent() != null) + Files.createDirectories(classPath.getParent()); Files.write(classPath, classfileBuffer); log.debug("Dump class ", className, " loaded by ", loader, " to ", classPath); } catch (Exception e) { diff --git a/jagent-impl/src/main/java/com/devexperts/jagent/JAgent.java b/jagent-impl/src/main/java/com/devexperts/jagent/JAgent.java index 1bbe350..82049fc 100644 --- a/jagent-impl/src/main/java/com/devexperts/jagent/JAgent.java +++ b/jagent-impl/src/main/java/com/devexperts/jagent/JAgent.java @@ -115,6 +115,8 @@ private void redefine(ClassFileTransformer transformer) ArrayList classes = new ArrayList<>(); HashSet done = new HashSet<>(); FastByteBuffer buf = new FastByteBuffer(); + CachingClassFileTransformer ourTransformer = transformer instanceof CachingClassFileTransformer ? + (CachingClassFileTransformer) transformer : null; for (int pass = 1; ; pass++) { classes.addAll(Arrays.asList(inst.getAllLoadedClasses())); List cdl = new ArrayList<>(classes.size()); @@ -125,6 +127,8 @@ private void redefine(ClassFileTransformer transformer) if (!done.add(clazz)) continue; String name = clazz.getName().replace('.', '/'); + if (ourTransformer != null && !ourTransformer.processClass(name, clazz.getClassLoader())) + continue; InputStream is = clazz.getResourceAsStream("/" + name + ".class"); buf.clear(); if (is != null) diff --git a/pom.xml b/pom.xml index a867f0e..81f68a7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.devexperts.jagent jagent - 1.4-SNAPSHOT + 1.4 pom JAgent @@ -169,11 +169,36 @@ + + + com.devexperts.jgitflow + jgitflow-maven-plugin + 1.0-m5.1-devexperts + + true + + jagent- + + true + [release] + + + + + + false + + bintray-devexperts + bintray-plugins + http://dl.bintray.com/devexperts/Maven + + + scm:git:https://stash.in.devexperts.com/scm/dxlab/jagent.git scm:git:ssh://git@stash.in.devexperts.com:7999/dxlab/jagent.git diff --git a/sample/agent/pom.xml b/sample/agent/pom.xml index de367ad..6cb37e6 100644 --- a/sample/agent/pom.xml +++ b/sample/agent/pom.xml @@ -3,7 +3,7 @@ sample com.devexperts.jagent.sample - 1.4-SNAPSHOT + 1.4 4.0.0 diff --git a/sample/core/pom.xml b/sample/core/pom.xml index 3a1be5f..5d8727a 100644 --- a/sample/core/pom.xml +++ b/sample/core/pom.xml @@ -3,7 +3,7 @@ sample com.devexperts.jagent.sample - 1.4-SNAPSHOT + 1.4 4.0.0 diff --git a/sample/pom.xml b/sample/pom.xml index 1bd6522..491bafc 100644 --- a/sample/pom.xml +++ b/sample/pom.xml @@ -3,7 +3,7 @@ jagent com.devexperts.jagent - 1.4-SNAPSHOT + 1.4 4.0.0 diff --git a/sample/test/pom.xml b/sample/test/pom.xml index 45a5dc0..78b5e72 100644 --- a/sample/test/pom.xml +++ b/sample/test/pom.xml @@ -3,7 +3,7 @@ sample com.devexperts.jagent.sample - 1.4-SNAPSHOT + 1.4 4.0.0 diff --git a/sample/transformer/pom.xml b/sample/transformer/pom.xml index 0e6552a..dad15bc 100644 --- a/sample/transformer/pom.xml +++ b/sample/transformer/pom.xml @@ -3,7 +3,7 @@ sample com.devexperts.jagent.sample - 1.4-SNAPSHOT + 1.4 4.0.0