Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JDT core doesn't resolve constant for wrapper
JDT core doesn't resolve constant for wrapper [message #1830377] Fri, 24 July 2020 12:06 Go to next message
Marcelo  Avancini is currently offline Marcelo AvanciniFriend
Messages: 3
Registered: July 2020
Junior Member
I am using JDT Core for a project and a problem is getting in the way.

The project is about collect some information from source code. A part of that requires that I resolve constant values and the API provides that. It works well for primitive values, but doesn't for wrappers.

For example, give following code using JDT:

node.resolveConstantExpressionValue();


It works very well with this code:

private static final int MY_CONST = 123;


But doesn't work with follow:

private static final Integer MY_CONST = 123;


I debugged for while and I found the logic that converts the value if it is an int (primitive) in following line:

https://github.com/eclipse/eclipse.jdt.core/blob/d6fdfb48c98dc3f94509f41f07432086fff67206/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java#L197

So my questions are:

- The Integer wrapper (or others) wouldn't have the same behavior and converts the value as well as done with primitives?

- Is there some other concept that I miss and explain this behavior?

- Is there some change that I could made to solve it?

Thank you!

[Updated on: Fri, 24 July 2020 14:53]

Report message to a moderator

Re: JDT core doesn't resolve constant for wrapper [message #1830490 is a reply to message #1830377] Mon, 27 July 2020 19:10 Go to previous messageGo to next message
Marcelo  Avancini is currently offline Marcelo AvanciniFriend
Messages: 3
Registered: July 2020
Junior Member
I'd made some changes to test and worked well to me. I put the change on a github PR: https://github.com/eclipse/eclipse.jdt.core/pull/59.

I know that the github is used as just a mirror, so let me know if there is other way to submit the PR.

[Updated on: Tue, 28 July 2020 14:26]

Report message to a moderator

Re: JDT core doesn't resolve constant for wrapper [message #1830510 is a reply to message #1830490] Tue, 28 July 2020 05:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Generally contributions are made by first opening a Bugzilla and committing the changes to Gerrit using the Bugzilla header in the commit message.

All the platform projects have Oomph setups that can be used as described in this tutorial:

https://wiki.eclipse.org/Eclipse_Platform_SDK_Provisioning

Here are some more details specific to JDT:

https://wiki.eclipse.org/JDT_UI/How_to_Contribute

The statement "Still for regular contributors / committers the below description is preferrable as it allows you to always use the latest I-Build, which seems not to work using the Oomph approach, which starts with a released Eclipse package" isn't true; you just need to choose the "Eclipse.org Application" -> "Eclipse SDK" -> Latest to use the Platforms "IBuild" as the development IDE.

If you follow the first tutorial, be sure to get the Gerrit account and use the Gerrit URIs for cloning. Also, if you follow that tutorial, you can go back to the Projects page after applying the configuration to reduce the number of projects that will be cloned into the workspace. You really only actually need the JDT projects...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: JDT core doesn't resolve constant for wrapper [message #1830529 is a reply to message #1830510] Tue, 28 July 2020 14:06 Go to previous message
Marcelo  Avancini is currently offline Marcelo AvanciniFriend
Messages: 3
Registered: July 2020
Junior Member
Thank you for reply, Ed.

I'm going to take a look and open the PR as well.
Previous Topic:Eclipse formatter from the CLI and UTF-8
Next Topic:How to get Debug Shell to use static imports?
Goto Forum:
  


Current Time: Sat Apr 20 02:59:08 GMT 2024

Powered by FUDForum. Page generated in 0.02965 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top