diff --git a/src/gfunction/gfunction.go b/src/gfunction/gfunction.go index 3d570241..27e14210 100644 --- a/src/gfunction/gfunction.go +++ b/src/gfunction/gfunction.go @@ -130,6 +130,7 @@ func MTableLoadGFunctions(MTable *classloader.MT) { Load_Util_Concurrent_Atomic_AtomicInteger() Load_Util_Concurrent_Atomic_Atomic_Long() Load_Util_HashMap() + Load_Util_HexFormat() Load_Util_Locale() Load_Util_Random() diff --git a/src/gfunction/javaUtilHexFormat.go b/src/gfunction/javaUtilHexFormat.go new file mode 100644 index 00000000..41bfec27 --- /dev/null +++ b/src/gfunction/javaUtilHexFormat.go @@ -0,0 +1,61 @@ +/* + * Jacobin VM - A Java virtual machine + * Copyright (c) 2024 by the Jacobin authors. Consult jacobin.org. + * Licensed under Mozilla Public License 2.0 (MPL 2.0) All rights reserved. + */ + +package gfunction + +import "jacobin/statics" + +// Implementation of some of the functions in in Java/lang/Class. + +func Load_Util_HexFormat() { + + MethodSignatures["java/util/HexFormat.()V"] = + GMeth{ + ParamSlots: 0, + GFunction: hexMapClinit, + } +} + +// hashMapHash accepts a pointer to an object and returns +// a uint64 MD5 hash value of the pointed-to thing +func hexMapClinit(params []interface{}) interface{} { + DIGITS := [256]int8{ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + } + sDigits := statics.Static{Type: "[B", Value: DIGITS} + statics.AddStatic("java/util/HexFormat.DIGITS", sDigits) + + UPPERCASE_DIGITS := [16]int8{ + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', + } + sUppercaseDigits := statics.Static{Type: "[B", Value: UPPERCASE_DIGITS} + statics.AddStatic("java/util/HexFormat.UPPERCASE_DIGITS", sUppercaseDigits) + + LOWERCASE_DIGITS := [16]int8{ + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', + } + sLowercaseDigits := statics.Static{Type: "[B", Value: LOWERCASE_DIGITS} + statics.AddStatic("java/util/HexFormat.LOWERCASE_DIGITS", sLowercaseDigits) + + return nil +}