Skip to content
New issue

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

JACOBIN-398 While tracing, FormatField returning "<ERROR..." --> DumpObject(title=why?/what?, indentation=0) #97

Merged
merged 3 commits into from
Nov 12, 2023

Conversation

texadactyl
Copy link
Collaborator

@texadactyl texadactyl commented Nov 12, 2023

While tracing, if there are field formatting errors for any reason, we will now dump the entire object.

Error conditions diagnosed in FormatField:

  • <ERROR nil class pointer!>
  • <ERROR FieldTable["value"] not found!> when FieldTable is nonempty

Error conditions diagnosed in fmtHelper (called by FormatField):

  • <ERROR Ftype=bool but unexpected Fvalue variable type: observed-type !>
  • <ERROR nil Fvalue!> E.g. Ftype is [B but the byte array pointer is nil

An object dump will always attempt to depict both the FieldTable contents and the Fields slice contents.
See the object/object_test.go unit testing.

E.g. Dump an object with a non-empty FieldTable but an empty Fields slice:

   DumpObject java/lang/madeUpClass {
   	Class: java/lang/madeUpClass
   	Field Table:
   		Fld myChar: (C) 'C'
   		Fld myFloat: (F) 1.000000
   		Fld myLong: (J) 42
   		Fld myByte: (B) 61
   		Fld myStaticTrue: (XZ) true
   		Fld myString: (Ljava/lang/String;) Hello, Unka Andoo !
   		Fld myDouble: (D) 2.000000
   		Fld myInt: (I) 42
   		Fld myShort: (S) 42
   		Fld myFalse: (Z) false
   	Field Slice is <empty>
   }

E.g. Dump an object with a non-empty Fields slice but an empty FieldTable:

DumpObject [B string] {
	Class: java/lang/madeUpClass
	Field Table is <empty>
	Field Slice (11):
		Fld ([B) 54 68 69 73 20 69 73 20 61 20 63 6f 6d 70 61 63 74 20 73 74 72 69 6e 67 20 66 72 6f 6d 20 61 20 47 6f 20 73 74 72 69 6e 67
		Fld (B) 00
		Fld (I) 0
		Fld (XZ) true
		Fld (L) <nil>
		Fld (L) <nil>
		Fld (L) <nil>
		Fld (L) <nil>
		Fld (L) <nil>
		Fld (Z) false
		Fld (L) <nil>
}

E.g. Currently, jacotest case "zippy" exhibits an object with both field structures being non-empty but missing the "value" field in the FieldTable. This error is caught in FormatField:

DumpObject <ERROR FieldTable["value"] not found!> {
	Class: java/io/File
	Field Table:
		Fld serialVersionUID: (XJ) 0
		Fld PREFIX_LENGTH_OFFSET: (XJ) 0
		Fld fs: (XLjava/io/FileSystem;) <nil>
		Fld pathSeparatorChar: (XC) '\x00'
		Fld pathSeparator: (XLjava/lang/String;) <nil>
		Fld UNSAFE: (XLjdk/internal/misc/Unsafe;) <nil>
		Fld filePath: (Ljava/nio/file/Path;) <nil>
		Fld prefixLength: (I) 0
		Fld status: (Ljava/io/File$PathStatus;) <nil>
		Fld separatorChar: (XC) '\x00'
		Fld separator: (XLjava/lang/String;) <nil>
		Fld PATH_OFFSET: (XJ) 0
		Fld $assertionsDisabled: (XZ) false
		Fld path: (Ljava/lang/String;) <nil>
	Field Slice (14):
		Fld (XLjava/io/FileSystem;) <nil>
		Fld (Ljava/lang/String;) <nil>
		Fld (Ljava/io/File$PathStatus;) <nil>
		Fld (I) 0
		Fld (XC) '\x00'
		Fld (XLjava/lang/String;) <nil>
		Fld (XC) '\x00'
		Fld (XLjava/lang/String;) <nil>
		Fld (XLjdk/internal/misc/Unsafe;) <nil>
		Fld (XJ) 0
		Fld (XJ) 0
		Fld (XJ) 0
		Fld (Ljava/nio/file/Path;) <nil>
		Fld (XZ) false
}

@texadactyl texadactyl changed the title While tracing, FormatField returning "<ERROR..." --> DumpObject(title=why?/what?, indentation=0) JACOBIN-398 While tracing, FormatField returning "<ERROR..." --> DumpObject(title=why?/what?, indentation=0) Nov 12, 2023
@texadactyl
Copy link
Collaborator Author

texadactyl commented Nov 12, 2023

@platypusguy - This is a bit off topic from the PR.

Note Fld pathSeparator: (XLjava/lang/String;) <nil> above. Shouldn't the Fvalue be "/" or "\"? Maybe I am confused.

It appears that when field type is XL (static reference) or L (non-static reference), in both FieldTable and the Fields slice,

  • Ftype <- field type concatenated with the field value
  • Fvalue <- nil

Is that correctly done in jvm/instantiate.go function createField?
Questions:

  • Ftype is "L" or "XL" and the Fvalue is "Lreference-name;"?
  • Ftype is correct as-is but Fvalue should be non-nil e.g. the string bytes?
  • Something else that is not intuitively obvious to me?

I get that byte arrays are initialized empty. My questions are about types.Ref.

@platypusguy platypusguy merged commit a209293 into platypusguy:main Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants