joern
joern copied to clipboard
[Bug] Type loss/erasure in compiled domain classes severely hurts interoperability
Describe the bug When invoking joern as a library (like in joernio/standalone-ext), the loss of type information across many domain classes breaks JVM-langauge interop, particularly with the switch to the EMT to provide property/traversal implicits.
For example, the generated Method
node is compiled as (from javap
, removing the fully qualified names for readability):
public class Method extends StoredNode implements MethodBase, CfgNode, Declaration
Because it doesn't have StaticType[MethodEMT]
when compiled, it lacks all of those traits like HasFilenameEMT
or HasFullNameEMT
. This means there's no way for a Method
node to satisfy the type constraints on traversals like
public final <NodeType extends StoredNode & StaticType<HasFullNameEMT>> Iterator<String> fullName$extension(Iterator);
There are other losses of type information, not exclusive to the EMTs.
For example, AstNode
becomes
public interface AstNode extends AstNodeBase
...lacking StoredNode
, and thus lacking the .file
implicit/extension.
Also, there are several cases where traversals' types get widened from Iterator<Int>
or Iterator<Boolean>
to Iterator<Object>
:
public Iterator<Object> offsetEnd(); // should return Iterator<int>...
public Iterator<NodeType> offsetEnd(int); // param correctly an int
public Iterator<NodeType> offsetEnd(Seq<Object>); // param is a seq of Objects?
To Reproduce Steps to reproduce the behavior:
- Look at classes in
codepropertygraph-domain-classes_3-1.7.1.jar
or generate classes using the flatgraph domain-classes-generator and compile - Use
javap
or an IDE which decompiles the classes to check signatures/types
Expected behavior Enough information is available in the compiled classes to be able to reasonably use the nodes/traversals/etc
Screenshots N/A
Desktop (please complete the following information): Should be irrelevant here but:
- OS: macOS 14.5
- Joern Version: 4.0.2, 4.0.8
- Java version: 17
- Scala version: 3.4.2 / 3.5.1-RC1
Additional context Add any other context about the problem here.