Byteman 2.0.1 released
by Andrew Dinn
The Byteman 2.0.1 patch release is now available from the JBoss maven
repo and from the byteman downloads page
http://www.jboss.org/downloads
This is mostly a patch release which fixes a miscellany of small but
perfectly formed issues recently uncovered by our intrepid user
community. However, it does als include two exciting new functions,
contributed courtesy of JBoss community member Kenji Suzuki and our very
own Bela Ban:
-- provide Windows batch script equivalents for the Linux command
scripts used to drive Byteman (thanks Kenji!)
-- modify BMUnit to look for rule scripts mentioned in @BMScript
annotations as resources on the classpath before resorting to loading
from the local file system (neat idea, Bela!)
Enjoy!
regards,
Andrew Dinn
-----------
12 years, 11 months
inner classes and param types
by Ales Justin
Anyone seen this, or how to make this deterministic ...
I have these 2 classes - (a) and (b) - see below.
And this code:
final Annotation[][] parameterAnnotations = constructor.getParameterAnnotations();
final Type[] genericParameterTypes = constructor.getGenericParameterTypes();
// If the class is a (non-static) member class, its constructors
// parameterTypes array will prefix the
// outer class instance, whilst the genericParameterTypes array isn't
// prefix'd -- not always true ...
int nesting = Reflections.getNesting(declaringClass.getJavaClass());
for (int i = 0; i < parameterTypes.length; i++) {
int gi = i - nesting;
Annotation[] annotations = (gi >= 0 && parameterAnnotations[gi].length > 0) ? parameterAnnotations[gi] : EMPTY;
Class<?> clazz = parameterTypes[i];
Type parameterType = genericParameterTypes[i];
So, the issue is - as I added "not always true" to the existing comment,
that "genericParameterTypes" are random in my case --
sometimes they have owner class prefixed == use case (a),
sometimes they don't == use case (b), hence resulting in ArrayIOOBE.
Any idea why is this so?
-Ales
---
(a)
public class Crasher {
protected class NonStaticInner {
public NonStaticInner(@Nonnull Integer a) {
System.out.println("Hi" + a);
}
protected class NonStaticInner2 {
public NonStaticInner2(@Nonnull Double a) {
System.out.println("Hi" + a);
}
}
}
}
(b)
public class ExampleTest {
...
public class NonContextual<T> {
final InjectionTarget<T> it;
final BeanManager manager;
public NonContextual(BeanManager manager, Class<T> clazz) {
this.manager = manager;
AnnotatedType<T> type = manager.createAnnotatedType(clazz);
this.it = manager.createInjectionTarget(type);
}
public CreationalContext<T> postConstruct(T instance) {
CreationalContext<T> cc = manager.createCreationalContext(null);
it.inject(instance, cc);
it.postConstruct(instance);
return cc;
}
public void preDestroy(T instance) {
it.preDestroy(instance);
}
}
}
12 years, 11 months