Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing @Injectable if @Resource has name which contains / (slash) #532

Closed
Saljack opened this issue Jul 25, 2018 · 3 comments
Closed

Missing @Injectable if @Resource has name which contains / (slash) #532

Saljack opened this issue Jul 25, 2018 · 3 comments
Assignees
Labels

Comments

@Saljack
Copy link

@Saljack Saljack commented Jul 25, 2018

jmockit version 1.40

I have project where are used @Resource(name = "xxx/XXX"). I am not able create @Injectable for this resource (Missing @Injectable for field). This is the same problem like #359 .
I think the solution for this problem is update method

public static String convertToLegalJavaIdentifierIfNeeded(@Nonnull String name) {

and add conversion for "/" as delimiter.

@rliesenfeld

This comment has been minimized.

Copy link
Member

@rliesenfeld rliesenfeld commented Jul 26, 2018

The "/" character is supported in the lookup attribute of @Resource, but not in name. I am not sure if it's valid for name to have slashes in the Java EE spec, but it seems wrong since "abc/Xyz" is actually a hierarchy with two names, while "abc-Xyz" or "abc.Xyz" is still a single name.

Any reason why your Resources are using name instead of lookup, for such composite names?

@Saljack

This comment has been minimized.

Copy link
Author

@Saljack Saljack commented Jul 26, 2018

I think "/" is valid for name. For examle EJB 3.0 and EJB 3.1 application bindings overview from IBM contains examples where slash is used in @EJB name (@EJB(name="ejb/FacadeRemoteRef") ). I agree with hierarchy and two names and I think it is the right reason why we use slash in names.
Solution should be use only the last name after slash. For example:

@Resource(name="abc/XYZ")
Resource resource;

and

@Injectable
Resource XYZ

I don't want change name to lookup I don't see any reason to change it.

@rliesenfeld

This comment has been minimized.

Copy link
Member

@rliesenfeld rliesenfeld commented Jul 27, 2018

Ok. I settled on what's probably a better solution: to fall back on matching the annotated field name, when no injectable is found which matches the name or lookup attributes.

@rliesenfeld rliesenfeld self-assigned this Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.