Skip to content

util:constant can't read static inner enums [SPR-5210] #9883

Closed
@spring-projects-issues

Description

@spring-projects-issues

Gert-Jan Schouten opened SPR-5210 and commented

If I have this code:

public enum AccountLevel {

NORMAL, MODERATOR, ADMINISTRATOR

}

then I can put this in my spring config:

<util:constant static-field="AccountLevel.NORMAL" />

Everything works fine. But if I have this code:

public class Account {

public enum Level {

    NORMAL, MODERATOR, ADMINISTRATOR
}

}

then I cannot do this:

<util:constant static-field="Account.Level.NORMAL" />

I have been thinking about this and came to the conclusion that this is impossible, because my inner enum is not static: You need an instance of Account, before you can have an Account.Level (just like inner classed), so I changed my code and made the enum static:

public class Account {

public static enum Level {

    NORMAL, MODERATOR, ADMINISTRATOR
}

}

But this:

<util:constant static-field="Account.Level.NORMAL" />

still does not work! Why? It should work, I think...


Affects: 2.5.5

Referenced from: commits eb1631f

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