|
35 | 35 |
|
36 | 36 | # Standard library |
37 | 37 | import collections |
| 38 | +import functools |
38 | 39 | import logging |
39 | 40 | import os |
40 | 41 | import struct |
@@ -906,6 +907,9 @@ def do_object(self, parent=None, ident=0): |
906 | 907 | and classdesc.flags & self.SC_WRITE_METHOD |
907 | 908 | or classdesc.flags & self.SC_EXTERNALIZABLE |
908 | 909 | and classdesc.flags & self.SC_BLOCK_DATA |
| 910 | + or classdesc.superclass is not None |
| 911 | + and classdesc.superclass.flags & self.SC_SERIALIZABLE |
| 912 | + and classdesc.superclass.flags & self.SC_WRITE_METHOD |
909 | 913 | ): |
910 | 914 | # objectAnnotation |
911 | 915 | log_debug( |
@@ -1709,6 +1713,38 @@ def __extra_loading__(self, unmarshaller, ident=0): |
1709 | 1713 | # Lists have their content in there annotations |
1710 | 1714 | self.extend(self.annotations[1:]) |
1711 | 1715 |
|
| 1716 | + @functools.total_ordering |
| 1717 | + class JavaPrimitiveClass(JavaObject): |
| 1718 | + """ |
| 1719 | + Parent of Java classes matching a primitive (Bool, Integer, Long, ...) |
| 1720 | + """ |
| 1721 | + def __init__(self, unmarshaller): |
| 1722 | + JavaObject.__init__(self) |
| 1723 | + self.value = None |
| 1724 | + |
| 1725 | + def __str__(self): |
| 1726 | + return str(self.value) |
| 1727 | + |
| 1728 | + def __repr__(self): |
| 1729 | + return repr(self.value) |
| 1730 | + |
| 1731 | + def __hash__(self): |
| 1732 | + return hash(self.value) |
| 1733 | + |
| 1734 | + def __eq__(self, other): |
| 1735 | + return self.value == other |
| 1736 | + |
| 1737 | + def __lt__(self, other): |
| 1738 | + return self.value < other |
| 1739 | + |
| 1740 | + class JavaBool(JavaPrimitiveClass): |
| 1741 | + def __bool__(self): |
| 1742 | + return self.value |
| 1743 | + |
| 1744 | + class JavaInt(JavaPrimitiveClass): |
| 1745 | + def __int__(self): |
| 1746 | + return self.value |
| 1747 | + |
1712 | 1748 | class JavaMap(dict, JavaObject): |
1713 | 1749 | """ |
1714 | 1750 | Python-Java dictionary/map bridge type |
@@ -1955,6 +1991,9 @@ def do_period(self, unmarshaller, data): |
1955 | 1991 | "java.util.HashSet": JavaSet, |
1956 | 1992 | "java.util.TreeSet": JavaTreeSet, |
1957 | 1993 | "java.time.Ser": JavaTime, |
| 1994 | + "java.lang.Boolean": JavaBool, |
| 1995 | + "java.lang.Integer": JavaInt, |
| 1996 | + "java.lang.Long": JavaInt, |
1958 | 1997 | } |
1959 | 1998 |
|
1960 | 1999 | def create(self, classdesc, unmarshaller=None): |
|
0 commit comments