We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在以下的代码中,code2graph 会报错
int[] test = new int[3]; test[0] = 1; test[1] = 2; test[2] = 3; System.out.println(test.length);
原因是 test.length 的 length 找不到它的 Class
test.length
实际上,数组的 length 属性是 Java 编译器在编译时给加上的,为其分配了 1 个字长的内存空间, 用于存储数组的长度。这个 length 属性相当于数组对象中一个 public final static int length = ?; 的属性
Java 中还有一个跟数组 length 属性类似的,也就是类的 class 属性,比如 String.class, 这个 class 也是编译器在编译时动态给加上的
.length .class 这类编译时才添加的属性,在 jdt 中是没有 Class 的 因此:
.length
.class
varBinding.getDeclaringClass() == null
解决方法: 在 gen.java 的 edu.pku.code2graph.gen.jdt.ExpressionVisitor.java 中 1120 行后添加判断 varBinding.getDeclaringClass() 是否为 null
edu.pku.code2graph.gen.jdt.ExpressionVisitor.java
varBinding.getDeclaringClass()
if (varBinding.getDeclaringClass() != null) { usePool.add( Triple.of( root, EdgeType.REFERENCE, varBinding.getDeclaringClass().getQualifiedName() + "." + varBinding.getName())); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在以下的代码中,code2graph 会报错
原因是
test.length
的 length 找不到它的 Class.length
.class
这类编译时才添加的属性,在 jdt 中是没有 Class 的因此:
解决方法:
在 gen.java 的
edu.pku.code2graph.gen.jdt.ExpressionVisitor.java
中 1120 行后添加判断varBinding.getDeclaringClass()
是否为 nullThe text was updated successfully, but these errors were encountered: