qmx / jitescript Goto Github PK
View Code? Open in Web Editor NEWJitescript - Java API for Bytecode
Home Page: http://blog.qmx.me
License: Apache License 2.0
Jitescript - Java API for Bytecode
Home Page: http://blog.qmx.me
License: Apache License 2.0
Followup to a discussion on IRC (freenode, channel `#dynjs).
I have taken on me to kickstart parboiled "1" development again, since it has halted two years ago, and have created grappa.
Basically: you write parsers in Java and create your parser with:
final MyParser parser = Parboiled.createParser(MyParser.class);
This does the following:
ParserClassNode
containing the bytecode of MyParser
);RuleMethod
in the ParserClassNode
, that is, methods defined in the base class returning a Rule
, perform a given number of transformations; those transformations are defined here.When you have a look at the classes defined here, what they all do (on the byte code copy) is to generate bytecode which is appended/prepended to the existing method bytecode.
And that is done using raw ASM...
Having googled around, I stumbled upon this library when watching a video on YouTube by the author of JRuby mentioning this library; but I don't see how I can use this library to modify existing bytecode?
An example of what I mean is here.
I know I'll have to modify this code one day (when I go Java 7 I want to go indy); but right now, I am looking for a library which can make it easier for me to generate that kind of "bytecode set", and there are many; a lot more such code extracts are available in the enclosing package. Can JiteScript help me here?
I don't know Java well, so I'd just like to leave this as a suggestion, without judgement:
Our static analysis suggests a change at https://github.com/qmx/jitescript/blob/master/src/main/java/me/qmx/jitescript/VisibleAnnotation.java#L34, to change value.getClass()
to value.getDeclaredClass()
. The former returns some derived class for enums that declare methods, whereas the latter returns the actual enum type.
I'm not sure if that's correct, but it was flagged as an error-prone pattern.
Hi,
I noticed that jitescript fails to build if the dependency on asm-all is replaced by asm-debug-all. Here is the error displayed:
src/main/java/me/qmx/jitescript/MethodDefinition.java:[58,36] error: incompatible types: ArrayList<VisibleAnnotation> cannot be converted to List<AnnotationNode>
src/main/java/me/qmx/jitescript/FieldDefinition.java:[25,34] error: incompatible types: ArrayList<VisibleAnnotation> cannot be converted to List<AnnotationNode>
This error doesn't happen with asm-all because the classes are stripped from the debug symbols and the generic signatures.
Maybe VisibleAnnotation should extend AnnotationNode so the list contains the type expected?
Modern Java complains about "raw types" when types such as Class
or Enum
are used; those should perhaps nowadays be spelled Class<?>
and Enum<?>
. Would you like a pull request for such a change?
hi,
about CodegenUtils public static String sig(Class retval, Class... params) {}
if method throws Excetions, how to do ?
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.