FasterXML / java-classmate

Library for introspecting generic type information of types, member/static methods, fields. Especially useful for POJO/Bean introspection.
http://fasterxml.com
Apache License 2.0
258 stars 42 forks source link

ArrayIndexOutOfBoundsException when resolving Object.class #30

Closed meszibalu closed 8 years ago

meszibalu commented 8 years ago

I am using classmate 1.3.1 and I get an exception when executing the following code:

TypeResolver resolver = new TypeResolver(); MemberResolver memberResolver = new MemberResolver(resolver);

ResolvedType type = resolver.resolve(Object.class); memberResolver.resolve(type, null, null);

The exception is: java.lang.ArrayIndexOutOfBoundsException: 0 at com.fasterxml.classmate.MemberResolver.resolve(MemberResolver.java:137) ...

It is interesting, because MemberResolver works on interfaces, abstract classes and annotations too, and it seems only the Object class is too much for it.

cowtowncoder commented 8 years ago

@meszibalu Thank you for reporting this. It is indeed interesting that it would fail on simplest class there is.

One question, which JDK are you using?

meszibalu commented 8 years ago

@cowtowncoder My java version is: openjdk version "1.8.0_72-internal" OpenJDK Runtime Environment (build 1.8.0_72-internal-b15) OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode)

I am using Debian Linux (jessie).

cowtowncoder commented 8 years ago

@meszibalu fixed for 1.3.2. Seems to work ok as far as I can see, but would appreciate verification if possible. Not yet sure when I'll release 1.3.2; could do it soon since bug reports are not very common around here.

meszibalu commented 8 years ago

@cowtowncoder I built your commit and it seems to be okay for me. I tested it for Object.class, int.class and for some other classes. Thanks :)

TeemuStenhammar commented 8 years ago

@cowtowncoder Hi, may I ask the situation of this fix getting released? Just ran to it and can work around it by handling Object differently, but I would like to avoid setting that setIncludeLangObject flag to true. Anyways, nice work with this lib!

cowtowncoder commented 8 years ago

TeemuStenhammar unfortunately I am quite swamped with work on multiple libraries, so haven't had a chance to release (there's one bug that was reported recently). But I'll go ahead and release 1.3.2 now, with just this fix, to ensure it's out.

cowtowncoder commented 8 years ago

Pushed 1.3.2 out, should sync to Maven Central within an hour or so.

TeemuStenhammar commented 8 years ago

Well, that was quick. Thank you!