This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 253472 - Declarative hints: No way to match against a literal
Summary: Declarative hints: No way to match against a literal
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 8
: P2 normal (vote)
Assignee: Svata Dedic
Depends on:
Reported: 2015-07-14 19:10 UTC by misterm
Modified: 2015-07-14 19:17 UTC (History)
4 users (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description misterm 2015-07-14 19:10:22 UTC
Use case:

I was trying to migrate a Spring project to Java EE 7. So I need rules to change things like:

@Scope("request") -> @RequestScoped
@Scope("view") -> @ViewAccessScoped

However, this is currently not possible with the current infrastructure. It should be simple to implement, because I did it in a hackish way:

   import java.lang.reflect.Field;
   import java.lang.reflect.Method;
   Method getSingleVariable;
	Method getLeaf;
	Method getValue;
	private Method getSingleVariable() throws Exception {
		if (getSingleVariable != null) {
			return getSingleVariable;

		getSingleVariable = Context.class.getDeclaredMethod("getSingleVariable", 
		return getSingleVariable;
	private Method getLeaf(Object treePath) throws Exception {
		if (getLeaf != null) {
			return getLeaf;

		return getLeaf = treePath.getClass().getMethod("getLeaf");
	private Method getValue(Object tree) throws Exception {
		if (getValue != null) {
			return getValue;

		return getValue = tree.getClass().getMethod("getValue");
	private String literal(Variable v) throws Exception {
		Object treePath = getSingleVariable().invoke(context, v);
		Object tree = getLeaf(treePath).invoke(treePath);
		return (String)getValue(tree).invoke(tree);
   public boolean isView(Variable v) throws Exception {
		return "view".equals(literal(v));
   public boolean isRequest(Variable v) throws Exception {
		return "request".equals(literal(v));
   public boolean isSession(Variable v) throws Exception {
		return "session".equals(literal(v));
   public boolean isApplication(Variable v) throws Exception {
		return "application".equals(literal(v));

This is of course as hackish as it can get, so we definitely need a permanent solution ;-)

Product Version = NetBeans IDE Dev (Build 20150701-686afc345584)
Operating System = Windows 8 version 6.2 running on amd64
Java; VM; Vendor = 1.8.0_40
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.40-b25