@@ -163,15 +163,33 @@ def _stock_java_converters() -> List[Converter]:
163163 predicate = lambda obj : isinstance (obj , bool ),
164164 converter = _jc .Boolean ,
165165 ),
166+ # int -> java.lang.Byte
167+ Converter (
168+ predicate = lambda obj , ** hints : isinstance (obj , int )
169+ and ("type" in hints and hints ["type" ] in ("b" , "byte" , "Byte" ))
170+ and _jc .Byte .MIN_VALUE <= obj <= _jc .Byte .MAX_VALUE ,
171+ converter = _jc .Byte ,
172+ priority = Priority .HIGH ,
173+ ),
174+ # int -> java.lang.Short
175+ Converter (
176+ predicate = lambda obj , ** hints : isinstance (obj , int )
177+ and ("type" in hints and hints ["type" ] in ("s" , "short" , "Short" ))
178+ and _jc .Short .MIN_VALUE <= obj <= _jc .Short .MAX_VALUE ,
179+ converter = _jc .Short ,
180+ priority = Priority .HIGH ,
181+ ),
166182 # int -> java.lang.Integer
167183 Converter (
168- predicate = lambda obj : isinstance (obj , int )
184+ predicate = lambda obj , ** hints : isinstance (obj , int )
185+ and ("type" not in hints or hints ["type" ] in ("i" , "int" , "Integer" ))
169186 and _jc .Integer .MIN_VALUE <= obj <= _jc .Integer .MAX_VALUE ,
170187 converter = _jc .Integer ,
171188 ),
172189 # int -> java.lang.Long
173190 Converter (
174- predicate = lambda obj : isinstance (obj , int )
191+ predicate = lambda obj , ** hints : isinstance (obj , int )
192+ and ("type" not in hints or hints ["type" ] in ("j" , "l" , "long" , "Long" ))
175193 and _jc .Long .MIN_VALUE <= obj <= _jc .Long .MAX_VALUE ,
176194 converter = _jc .Long ,
177195 priority = Priority .NORMAL - 1 ,
@@ -184,7 +202,8 @@ def _stock_java_converters() -> List[Converter]:
184202 ),
185203 # float -> java.lang.Float
186204 Converter (
187- predicate = lambda obj : isinstance (obj , float )
205+ predicate = lambda obj , ** hints : isinstance (obj , float )
206+ and ("type" not in hints or hints ["type" ] in ("f" , "float" , "Float" ))
188207 and (
189208 math .isinf (obj )
190209 or math .isnan (obj )
@@ -194,7 +213,8 @@ def _stock_java_converters() -> List[Converter]:
194213 ),
195214 # float -> java.lang.Double
196215 Converter (
197- predicate = lambda obj : isinstance (obj , float )
216+ predicate = lambda obj , ** hints : isinstance (obj , float )
217+ and ("type" not in hints or hints ["type" ] in ("d" , "double" , "Double" ))
198218 and (
199219 math .isinf (obj )
200220 or math .isnan (obj )
0 commit comments