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

Allow application bytecode transformation over plain byte arrays #12

Closed
Sanne opened this issue Sep 6, 2018 · 4 comments
Closed

Allow application bytecode transformation over plain byte arrays #12

Sanne opened this issue Sep 6, 2018 · 4 comments
Labels
kind/enhancement New feature or request
Milestone

Comments

@Sanne
Copy link
Member

Sanne commented Sep 6, 2018

We need Hibernate ORM to apply its own bytecode transformation logic on the user's JPA model.

The API we have in ORM is this one:

while Shamrock expects a Function<String, Function<ClassVisitor, ClassVisitor>> function; I don't see an easy way to adapt to this.

Would be nice to also expose the option to register a processor which works on plain byte[] rather than ASM class visitors?

@Sanne Sanne added the kind/enhancement New feature or request label Sep 6, 2018
@dmlloyd
Copy link
Member

dmlloyd commented Sep 6, 2018

I believe you could adapt it by returning a Function which returns a subclass of ClassWriter, which calls your transform at visitEnd and then uses a ClassReader initialized with the resultant class bytes to accept the passed-in ClassVisitor.

@Sanne
Copy link
Member Author

Sanne commented Sep 6, 2018

interesting idea! but visitEnd() is final :(

I'll play with that.

@dmlloyd
Copy link
Member

dmlloyd commented Sep 6, 2018

Ah, in that case you should create a ClassVisitor subclass whose delegate is a ClassWriter. Same idea though.

@Sanne
Copy link
Member Author

Sanne commented Sep 6, 2018

Prototyped an alternative based on David's suggestion:

I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants