Skip to content

Commit

Permalink
JACOBIN-563 Added polish and documentary comments to convenience func…
Browse files Browse the repository at this point in the history
…tion to identify the type of array
  • Loading branch information
platypusguy committed Aug 11, 2024
1 parent f5d1cff commit 32e2585
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/object/array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func TestGetArrayType(t *testing.T) {
t.Errorf("did not get expected 'I' for I, got: %s", retVal)
}

retVal = GetArrayType("[Ljava/lang/Object;")
if retVal != "Ljava/lang/Object;" {
t.Errorf("did not get expected 'Ljava/lang/Object;', got: %s", retVal)
}

retVal = GetArrayType("")
if retVal != "" {
t.Errorf("did not get expected empty string for an empty string, got %s", retVal)
Expand Down
3 changes: 3 additions & 0 deletions src/object/arrays.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func JdkArrayTypeToJacobinType(jdkType int) int {
}
}

// identifies the type of entry that the array is made up of
// i.e., primitives or specific references. Note if the array is a
// reference array, the trailing ; is *not* removed.
func GetArrayType(arrayType string) string {
typeChars := []byte(arrayType)
for index, char := range typeChars {
Expand Down

0 comments on commit 32e2585

Please sign in to comment.