-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
Labels
Milestone
Description
Guava Version
33.4.8-jre
Description
TypeToken#getRawType is needlessly expensive for TypeToken instances where the runtime type is already a Class; it allocates an ImmutableSet builder, a TypeVisitor. Ideally for Class / ParameterizedType, no allocations would occur.
Example
TypeToken.of(Object.class).getRawType(); // ideally shouldn't allocate
new TypeToken<List<Object>>(){}.getRawType(); // ideally shouldn't allocate, or should allocate less
Expected Behavior
I would not expect getRawType
to allocate so heavily for trivial TypeTokens.
Actual Behavior
Several GBs of allocations observed in a 3 minute profile from a production application, or 1% of allocations.
Packages
com.google.common.reflect
Platforms
No response
Checklist
-
I agree to follow the code of conduct.
-
I can reproduce the bug with the latest version of Guava available.