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

Graal support - reflection and runtime loading #777

Closed
raphw opened this issue Nov 21, 2019 · 8 comments
Closed

Graal support - reflection and runtime loading #777

raphw opened this issue Nov 21, 2019 · 8 comments
Assignees
Milestone

Comments

@raphw
Copy link
Owner

raphw commented Nov 21, 2019

Add support for running Byte Buddy on Graal native image by offering a runtime mode where generated classes are cached in a location and retreived in a different runtime mode such that no runtime code generation needs to take place.

The final API should ideally not require any changes to make it automatically applicable for any Byte Buddy user, direct or indirect.

Also, files for required reflection should be added as a convenience to support the runtime.

@raphw raphw self-assigned this Nov 21, 2019
@raphw raphw added this to the 1.10.3 milestone Nov 21, 2019
Repository owner deleted a comment from webfolderio Nov 22, 2019
@gruenich
Copy link

gruenich commented Aug 4, 2021

Probably the target milestone is no longer valid. Do you mind changing it or removing it altogether?

@raphw
Copy link
Owner Author

raphw commented Aug 4, 2021

I abuse the field to note the report version. Sorry for the confusion.

@dthommes
Copy link

Hi Rafael,

I was also looking for a similar solution, as we are having a lot of Mockito tests that we are trying to run with Graal's new JUnit native support. Mockito uses ByteBuddy to generate classes at runtime. So, I found this issue here.

Investigating further, I saw that dynamic class loading is a PR in the Graal project that has recently been merged:

oracle/graal#2442

So maybe, ByteBuddy can leverage the upcoming functionality of Graal to realize this feature. What do you think?

@raphw
Copy link
Owner Author

raphw commented Aug 11, 2021

Interesting. This would require that the default naming strategy is deterministic what is certainly possible, but it would likely also require reflection to work but this should be picked up by the agent. I will certainly look into this!

@raphw
Copy link
Owner Author

raphw commented Nov 2, 2021

Byte Buddy can now kind of work with this, as long as class names are deterministic. There are still some rough edges but we are moving forward, at least!

@mosche
Copy link

mosche commented Dec 6, 2022

@raphw Pretty awesome to see this working out of the box if collecting predefined classes using an agent run 🎉

Though, I noticed predefined classes are not collected if the dynamic type is loaded using ClassLoadingStrategy.UsingLookup.of(MethodHandles$Lookup). Is there any way to get this to work or continue using the old INJECTION strategy on Java 11 with the GraalVM agent?

@raphw
Copy link
Owner Author

raphw commented Dec 7, 2022

This would be a bug in Graal if so. Byte Buddy only adjiusts its default class naming strategy to work with the Graal agent out of the box. It's Graal that is responsible of collecting class files.

@mosche
Copy link

mosche commented Dec 7, 2022

Thanks @raphw! In deed, classes injected into the system class loader are skipped (oracle/graal#4248). Unfortunately, that's what will typically happen when defining a class using a lookup :/

@raphw raphw closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants