rustyx
rustyx

Reputation: 85481

How to dump an in-memory generated class to a file

I am getting some exceptions in a generated class sun.reflect.GeneratedMethodAccessor1548.invoke(). Is it possible to dump its code to a file or browse it somehow at runtime? It's part of a very large application with many third-party libs and I do not even know which library generated this class in the first place.

--

The last stacktrace is:

java.lang.IllegalArgumentException: java.lang.ClassCastException@60b4bc67
    at sun.reflect.GeneratedMethodAccessor1548.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_51]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_51]
    at com.github.mustachejava.reflect.ReflectionWrapper.call(ReflectionWrapper.java:63) ~[compiler-0.8.13.jar:na]
    at com.github.mustachejava.reflect.ReflectionObjectHandler.unwrap(ReflectionObjectHandler.java:34) ~[compiler-0.8.13.jar:na]
    at com.github.mustachejava.reflect.guards.WrappedGuard.apply(WrappedGuard.java:33) ~[compiler-0.8.13.jar:na]
    at com.github.mustachejava.reflect.GuardedWrapper.guardCall(GuardedWrapper.java:40) ~[compiler-0.8.13.jar:na]
    at com.github.mustachejava.reflect.ReflectionWrapper.call(ReflectionWrapper.java:57) ~[compiler-0.8.13.jar:na]
    at com.github.mustachejava.reflect.GuardedBinding.get(GuardedBinding.java:66) ~[compiler-0.8.13.jar:na]
    at com.github.mustachejava.codes.DefaultCode.get(DefaultCode.java:105) ~[compiler-0.8.13.jar:na]
    ... 98 common frames omitted

(There are no more "caused by" traces)

Upvotes: 0

Views: 569

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533730

The class is generated by the JVM to optimise the use of reflection. This should be the cause of an error unless there is a bug in the JVM, in which case you need to upgrade. More likely there is a bug in the code this method calls.

Upvotes: 1

Related Questions