ArrayDemo.java DOM Structure - checkmarx-ts/CxDOM-Types GitHub Wiki
Sample Code
Java file: ArrayDemo.java
class ArrayDemo {
public static void main(String[] args) {
// declares an array of integers
int[] anArray;
// allocates memory for 10 integers
anArray = new int[10];
// initialize first element
anArray[0] = 100;
System.out.println("Element at index 0: " + anArray[0]);
}
}
DOM Types line by line
line 1
class ArrayDemo {
- ArrayDemo | ClassDecl
line 2
public static void main(String[] args) {
- Type References | TypeRefCollection
- Members | MemberDeclCollection
- main | MethodDecl
- void | TypeRef
- Parameter Declarations | ParamDeclCollection
- args | ParamDecl
- String | TypeRef
- [] | RankSpecifier
- Statements | StatementCollection
line 3
int[] anArray;
- VariableDeclStmt | VariableDeclStmt
- int | TypeRef
- [] RankSpecifier
- anArray | Declarator
- null | NullLiteral
line 4
anArray = new int[10];
- ExprStmt | ExprStmt
- AssignExpr | AssignExpr
- anArray | UnknownReference
- ArrayCreateExpr | ArrayCreateExpr
- 10 | IntegerLiteral
- ArrayInitializer | ArrayInitializer
- int | TypeRef
- [] | RankSpecifier
line 5
anArray[0] = 100;
- ExprStmt | ExprStmt
- AssignExpr | AssignExpr
- anArray | IndexerRef
- anArray | UnknownReference
- 0 | IntegerLiteral
- 100 | IntegerLiteral
line 6
System.out.println("Element at index 0: " + anArray[0]);
- ExprStmt | ExprStmt
- println | MethodInvokeExpr
- println | MethodRef
- out | MemberAccess
- System | UnknownReference
- Param | Param
- BinaryExpr | BinaryExpr
- "Element at index 0: " | StringLiteral
- anArray | IndexerRef
- anArray | UnknownReference
- 0 | **IntegerLiteral **