修订版 | 30 (tree) |
---|---|
时间 | 2015-03-26 22:12:16 |
作者 | cottoncandy |
(empty log message)
@@ -17,7 +17,7 @@ | ||
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Default transformer. |
20 | - * | |
20 | + * | |
21 | 21 | * @author CottonCandy |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
@@ -24,10 +24,11 @@ | ||
24 | 24 | public class DefaultTransformer implements ClassFileTransformer { |
25 | 25 | |
26 | 26 | @Override |
27 | - public byte[] transform(final ClassLoader loader, final String className, final Class<?> classBeingRedefined, | |
28 | - final ProtectionDomain protectionDomain, final byte[] classfileBuffer) throws IllegalClassFormatException { | |
27 | + public byte[] transform(final ClassLoader loader, final String className, | |
28 | + final Class<?> classBeingRedefined, final ProtectionDomain protectionDomain, | |
29 | + final byte[] classfileBuffer) throws IllegalClassFormatException { | |
29 | 30 | |
30 | - if (loader == null) return classfileBuffer; | |
31 | + if (loader == null || loader.getParent() == null) return classfileBuffer; | |
31 | 32 | if (className.startsWith("javassist")) return classfileBuffer; |
32 | 33 | if (className.startsWith("jp/sourceforge/cottoncandy")) return classfileBuffer; |
33 | 34 |
@@ -8,7 +8,7 @@ | ||
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Behavior. |
11 | - * | |
11 | + * | |
12 | 12 | * @author CottonCandy |
13 | 13 | * @since 1.0 |
14 | 14 | */ |
@@ -26,7 +26,7 @@ | ||
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Constructs behavior. |
29 | - * | |
29 | + * | |
30 | 30 | * @param target The target method. |
31 | 31 | * @param scope The scope of this behavior. |
32 | 32 | */ |
@@ -38,7 +38,7 @@ | ||
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Sets method handler. |
41 | - * | |
41 | + * | |
42 | 42 | * @param <T> The behavior handler type. |
43 | 43 | * @param handler The method handler. can't be null. |
44 | 44 | * @return The specified handler on parameter. |
@@ -50,7 +50,7 @@ | ||
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Method handler install with specific callers. |
53 | - * | |
53 | + * | |
54 | 54 | * @param <T> The behavior handler type. |
55 | 55 | * @param handler The method handler. can't be null. |
56 | 56 | * @param enableCallers The method handler enabled in specified callers. |
@@ -57,15 +57,16 @@ | ||
57 | 57 | * @param disableCallers The method handler disabled in specified callers. |
58 | 58 | * @return The specified handler on parameter. |
59 | 59 | */ |
60 | - public <T extends BehaviorHandler> T setHandler(final T handler, final Set<Class<?>> enableCallers, | |
61 | - final Set<Class<?>> disableCallers) { | |
60 | + public <T extends BehaviorHandler> T setHandler(final T handler, | |
61 | + final Set<Class<?>> enableCallers, final Set<Class<?>> disableCallers) { | |
62 | 62 | |
63 | 63 | if (handler == null) throw new NullPointerException(); |
64 | 64 | Set<Class<?>> es = enableCallers == null ? Collections.<Class<?>>emptySet() : enableCallers; |
65 | - Set<Class<?>> ds = disableCallers == null ? Collections.<Class<?>>emptySet() : disableCallers; | |
65 | + Set<Class<?>> ds = disableCallers == null ? Collections.<Class<?>>emptySet() | |
66 | + : disableCallers; | |
66 | 67 | |
67 | 68 | /* |
68 | - * Check overlapping of callers. | |
69 | + * Checks overlapping of callers. | |
69 | 70 | */ |
70 | 71 | List<Class<?>> overlappingCallers = new ArrayList<Class<?>>(es); |
71 | 72 | overlappingCallers.retainAll(ds); |
@@ -88,7 +89,7 @@ | ||
88 | 89 | |
89 | 90 | /** |
90 | 91 | * Returns the target method. |
91 | - * | |
92 | + * | |
92 | 93 | * @return The target method. |
93 | 94 | */ |
94 | 95 | Method getMethod() { |
@@ -98,7 +99,7 @@ | ||
98 | 99 | |
99 | 100 | /** |
100 | 101 | * Returns the scope of this behavior. |
101 | - * | |
102 | + * | |
102 | 103 | * @return The scope of this behavior. |
103 | 104 | */ |
104 | 105 | BehaviorScope getScope() { |
@@ -108,7 +109,7 @@ | ||
108 | 109 | |
109 | 110 | /** |
110 | 111 | * Returns the method handler. |
111 | - * | |
112 | + * | |
112 | 113 | * @return The method handler. |
113 | 114 | */ |
114 | 115 | BehaviorHandler getHandler() { |
@@ -118,7 +119,7 @@ | ||
118 | 119 | |
119 | 120 | /** |
120 | 121 | * Returns true if contains the enabled-filter or the disabled-filter. |
121 | - * | |
122 | + * | |
122 | 123 | * @return true if contains the enabled-filter or the disabled-filter, |
123 | 124 | * otherwise returns false. |
124 | 125 | */ |
@@ -129,7 +130,7 @@ | ||
129 | 130 | |
130 | 131 | /** |
131 | 132 | * Returns the enabled callers. |
132 | - * | |
133 | + * | |
133 | 134 | * @return The enabled callers |
134 | 135 | */ |
135 | 136 | Set<Class<?>> getEnabledCallers() { |
@@ -139,7 +140,7 @@ | ||
139 | 140 | |
140 | 141 | /** |
141 | 142 | * Returns the disabled callers. |
142 | - * | |
143 | + * | |
143 | 144 | * @return The disabled callers. |
144 | 145 | */ |
145 | 146 | Set<Class<?>> getDisabledCallers() { |
@@ -19,7 +19,7 @@ | ||
19 | 19 | <dependency> |
20 | 20 | <groupId>org.javassist</groupId> |
21 | 21 | <artifactId>javassist</artifactId> |
22 | - <version>3.18.1-GA</version> | |
22 | + <version>3.18.2-GA</version> | |
23 | 23 | <scope>runtime</scope> |
24 | 24 | </dependency> |
25 | 25 | </dependencies> |