Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable validation of identifiers in Byte Buddy

I am working on a JVM-based programming language and I use Byte Buddy for the code generator. The language is somewhat similar to Java but typically uses annotations where Java would use keywords. Some example annotations are public, private, extends, override, singleton or inject.

Unlike the Java Language Specification, the Java Virtual Machine Specification imposes very few restrictions on class names, and names like extends or public are perfectly valid from JVM-perspective. However, when I try to generate annotation classes with a name that happens to be a Java keyword I get an IllegalStateException "Illegal type name" from Byte Buddy's InstrumentedType class.

How can I circumvent the validation that is specific to the Java language and use more lenient validation rules that follow the Java Virtual Machine Specification instead?

like image 627
raner Avatar asked Sep 18 '25 23:09

raner


1 Answers

You can simply disable validation:

new ByteBuddy().with(TypeValidation.DISABLED);
like image 54
Rafael Winterhalter Avatar answered Sep 20 '25 12:09

Rafael Winterhalter