Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: facebook/pfff
base: f498de0aeb
...
head fork: facebook/pfff
compare: 49c3a24941
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
19 lang_bytecode/analyze/graph_code_bytecode.ml
@@ -31,7 +31,9 @@ open JClassLow
* - package lookup, all names are resolved in the bytecode
* (still need a class lookup for fields/methods though ...)
* - handling nested classes, they are compiled in another class
- * with a $ suffix
+ * with a '$' used as a separator instead of '.'
+ * - handling anonymous classes, they are compiled in another class with
+ * a '$N' suffix.
* - handling generics?
* - type checking to resolve certain method calls, the bytecode is fully
* typed (a bit like TAL), one can get the type of each 'invoke' opcode
@@ -167,6 +169,10 @@ let add_use_edge env dst =
g +> G.add_edge (src, dst) G.Use;
()
+(*****************************************************************************)
+(* Lookup *)
+(*****************************************************************************)
+
let (lookup2:
Graph_code.graph -> Graph_code.node -> string -> Graph_code.node option) =
fun g start fld ->
@@ -201,6 +207,10 @@ let lookup g n s =
)
)
+(*****************************************************************************)
+(* Bytecode<->Java connection *)
+(*****************************************************************************)
+
let unmangle graph_java (full_str_bytecode_name, kind) =
let xs = Common.split "\\." full_str_bytecode_name in
let (package, bytecode_name_entity) =
@@ -210,7 +220,12 @@ let unmangle graph_java (full_str_bytecode_name, kind) =
)
in
let ys = Common.split "\\$" bytecode_name_entity in
-
+ let ys =
+ if ys +> List.exists (fun s -> s =~ "[0-9]+")
+ (* todo: look in graph_java for the corresponding anon_xxx *)
+ then [List.hd ys]
+ else ys
+ in
let full_name = package ++ ys in
Common.join "." full_name, kind
View
18 tests/bytecode/codegraph/AnonClass.java
@@ -0,0 +1,18 @@
+package Foo;
+class AnonClass {
+ void foo1() {
+ Object o = new Object() {
+
+ };
+ Object o2 = new Object() {
+
+ };
+ }
+ class NestedClass {
+ void foo1() {
+ Object o = new Object() {
+
+ };
+ }
+ }
+}
View
6 tests/bytecode/codegraph/Makefile
@@ -1,4 +1,5 @@
-SRC=Clone.java TestException.java NestedClass.java GenericClass.java
+SRC=Clone.java TestException.java NestedClass.java GenericClass.java \
+ AnonClass.java
OBJS=$(SRC:.java=.class)
@@ -9,6 +10,9 @@ all: graph_code.marshall
graph_code.marshall: $(OBJS)
~/pfff/codegraph -symlinks -lang bytecode -build .
+prolog:
+ ~/pfff/codequery -lang bytecode -build .
+
.SUFFIXES: .java .class
.java.class:

No commit comments for this range

Something went wrong with that request. Please try again.