Comments (4)
Turns out regex is the wrong tool for the job once you go past simple method signatures and get into heavy generics.
Looks like a full parser like ANTLR is needed.
http://stackoverflow.com/questions/3007139/regex-to-match-a-java-method-signature
Will investigate further to decide correct fix.
from jitwatch.
If this can help, parboiled provides a Java parser in its examples section: https://github.com/sirthias/parboiled/tree/master/examples-java/src/main/java/org/parboiled/examples/java/
from jitwatch.
Thanks :)
Thinking about this more, JITWatch knows the declared method on the Class e.g.
public static java.lang.Object[] java.util.Arrays.copyOf(java.lang.Object[],int,java.lang.Class)
and is trying to create a regex that will match this in the Java source file (a big String) by adding wildcards for things it cannot know (variable names, if types are fully qualified, etc.)
Currently it comes up with:
^(.*)public static ([0-9a-zA-Z_\.]*)Object\[\] copyOf( )*\(( )*([0-9a-zA-Z_\.]*)Object\[\]( )+([0-9a-zA-Z_]+),( )*int( )+([0-9a-zA-Z_]+),( )*([0-9a-zA-Z_\.]*)Class( )+([0-9a-zA-Z_]+)( )*\)(.*)$
Which will match with the type-erased signature but not with the generics syntactic sugar.
Given that generics can substitute the type names with E,T,U, ... I think the best solution might be to try a first pass search with the regex and then attempt a "best fit" search if that fails.
from jitwatch.
Added best match fallback algorithm where regex fails to match source code method signatures with generics.
from jitwatch.
Related Issues (20)
- how to set config for openjdk built by source files HOT 11
- I can't see the assembly instructions. HOT 2
- Fix gradle build to find FreeLogJ HOT 1
- Fix code cache visualisation since segmented code cache
- Fix auxiliary scripts which assume local lib folder HOT 1
- hsdis download failed on x86 mac HOT 2
- JITWatch shows garbled characters HOT 5
- After the SpringBoot project adds source and class to the config, the following error occurs when you click start HOT 5
- NPE occured from Tag.getAttributes() HOT 3
- The button in the tool is garbled HOT 2
- NPE on "Chain" button HOT 11
- java.lang.VerifyError: Cannot inherit from final class HOT 2
- compile ok but see nothing
- Unable to see source code for project classes as well as java lang classes HOT 11
- Gradle build is broken. HOT 2
- Add compilation flags HOT 3
- Add JMH in Sandbox HOT 1
- Any plans to support the Vector API? HOT 4
- tableswitch and Method size HOT 4
- Support for Azul Prime
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jitwatch.