CachedClassMirrors.getDeclaredMethods should never return null #11

Closed
tstockwell opened this Issue Oct 22, 2012 · 0 comments

Projects

None yet

2 participants

@tstockwell

I have created a classloader that does kilim weaving at runtime. I ran into a problem where the kilim weaver tosses a NullPointerException when trying to weave an interface class that had no declared methods. Turned out to be caused by the fact that the CachedClassMirrors.getDeclaredMethods method returns null for such a class. Since the caller did not check for null this caused a NullPointerException. The CachedClassMirrors.getDeclaredMethods method should return an empty array in this case.

Here's the old version of the method...


    public MethodMirror[] getDeclaredMethods() {
        return declaredMethods;
    }

Here's the new version...


    public MethodMirror[] getDeclaredMethods() {
        if (declaredMethods == null)
            return new MethodMirror[0];
        return declaredMethods;
    }
@kilim kilim pushed a commit that referenced this issue Oct 28, 2012
@sriram-srinivasan sriram-srinivasan Fixes for issues #11,12,13 contributed by tstockwell.
	modified:   src/kilim/mirrors/CachedClassMirrors.java
	modified:   src/kilim/mirrors/Detector.java
125d6f8
@kilim kilim closed this Oct 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment