Skip to content

Commit e190285

Browse files
committed
pyBoolean.__tojava__(Object.class) now returns a Boolean instead of an Integer. Also used valueOf static methods instead of constructors.
1 parent 22e1f67 commit e190285

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/org/python/core/PyBoolean.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,24 @@ final boolean bool___nonzero__() {
7676
}
7777

7878
public Object __tojava__(Class c) {
79+
if (c == Boolean.TYPE || c == Boolean.class ||
80+
c == Object.class ) {
81+
return Boolean.valueOf(value);
82+
}
7983
if (c == Integer.TYPE || c == Number.class ||
80-
c == Object.class || c == Integer.class ||
81-
c == Serializable.class)
82-
{
83-
return new Integer(value ? 1 : 0);
84+
c == Integer.class) {
85+
return Integer.valueOf(value ? 1 : 0);
8486
}
85-
86-
if (c == Boolean.TYPE || c == Boolean.class)
87-
return new Boolean(value);
8887
if (c == Byte.TYPE || c == Byte.class)
89-
return new Byte((byte)(value ? 1 : 0));
88+
return Byte.valueOf((byte)(value ? 1 : 0));
9089
if (c == Short.TYPE || c == Short.class)
91-
return new Short((short)(value ? 1 : 0));
90+
return Short.valueOf((short)(value ? 1 : 0));
9291
if (c == Long.TYPE || c == Long.class)
93-
return new Long(value ? 1 : 0);
92+
return Long.valueOf(value ? 1 : 0);
9493
if (c == Float.TYPE || c == Float.class)
95-
return new Float(value ? 1 : 0);
94+
return Float.valueOf(value ? 1 : 0);
9695
if (c == Double.TYPE || c == Double.class)
97-
return new Double(value ? 1 : 0);
96+
return Double.valueOf(value ? 1 : 0);
9897
return super.__tojava__(c);
9998
}
10099

0 commit comments

Comments
 (0)