Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduced InnerClasses propagation #491

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbellenger
Copy link

Hello from Airbnb!

We're using javassist to generate a large number of classfiles. It's been a great fit for our needs so far, thanks for sharing this library!

I ran into an issue where creating a class with a large number of nested classes was generating enormous class files and would frequently run out of memory. I think the issue is in CtClassType.makeNestedClass, which copies the entire InnerClassesAttribute from the outer class into inner classes.

This has the result of taking n**2 space relative to the number of nested classes. This behavior is also not what javac does (see example, particularly the "InnerClasses" at the very bottom which does not include sibling classes).

This PR changes makeNestedClass to only copy the outer-nested relationship into the new nested class' InnerClassesAttribute. I wasn't sure where to add a test for this so I put one into JvstTest5 hoping that someone will tell me where this really belongs.

@jbellenger jbellenger changed the title don't copy all InnerClassAttribute into nested classes reduced InnerClasses propagation Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant