java.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package javapkg
  5. import (
  6. "Java/java/lang/Float"
  7. "Java/java/lang/Integer"
  8. "Java/java/lang/System"
  9. "Java/java/util/Collections"
  10. "Java/java/util/jar/JarFile"
  11. "fmt"
  12. )
  13. func SystemCurrentTimeMillis() int64 {
  14. return System.CurrentTimeMillis()
  15. }
  16. func FloatMin() float32 {
  17. return Float.MIN_VALUE
  18. }
  19. func ManifestName() string {
  20. return JarFile.MANIFEST_NAME
  21. }
  22. func IntegerBytes() int {
  23. return Integer.SIZE
  24. }
  25. func IntegerValueOf(v int32) int32 {
  26. i, _ := Integer.ValueOf(v)
  27. return i.IntValue()
  28. }
  29. func IntegerDecode(v string) (int32, error) {
  30. i, err := Integer.Decode(v)
  31. if err != nil {
  32. return 0, fmt.Errorf("wrapped error: %v", err)
  33. }
  34. // Call methods from super class
  35. i.HashCode()
  36. return i.IntValue(), nil
  37. }
  38. func IntegerParseInt(v string, radix int32) (int32, error) {
  39. return Integer.ParseInt(v, radix)
  40. }
  41. func ProvokeRuntimeException() (err error) {
  42. defer func() {
  43. err = recover().(error)
  44. }()
  45. Collections.Copy(nil, nil)
  46. return
  47. }