Skip to content

primitive vs wrapper objects abiguity inside the container [SPR-5881] #10550

Closed
@spring-projects-issues

Description

@spring-projects-issues

Costin Leau opened SPR-5881 and commented

The container could be more explicit about its treatment of primitive vs wrapper objects. Consider the following example:

Foo(Boolean bool)
Foo(boolean bool)

and the configuration

<bean class="Foo">
    <constructor-arg>
         <value type="boolean">true</value>
    </constructor-arg>
</bean>

The Boolean constructor is called instead of the primitive one since the primitives are always wrapped at runtime. Considering the red-herring that primitives are, it would be saner to actually get an exception as the case is ambiguous - both constructor apply and it's unclear who should be used.
The work-around for people that depend on this behaviour is to specify a clear type on the constructor arg:

<constructor-arg value="java.lang.Boolean">....

Affects: 3.0 M3

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions