Community
Participate
Working Groups
I20060328-0010 Given: public void foo(Object o) { boolean b = o.getClass().isEnum(); } In a 1.5 project with an 1.5 JRE 1. Select isEnum 2. Inline ->Unable to resolve corresponding method declaration 3. Ctrl-Click on isEnum ->Method declaration is shown 4. Set the compiler compliance level to 1.4 for the project 5. Inline 'isEnum' ->The method declaration contains compile errors. Fix them. 6. Look at probelms view ->No errors
The problem is in CompilationUnit#findDeclaringNode(String key). In InlineMethodRefactoring.java:429, I call that method with key "Lxy/Try;&Ljava/lang/Class<!Ljava/lang/Class;+Ljava/lang/Object;96;>;.isEnum()Z", which comes from the invocation's binding for isEnum(). When I use #findDeclaringNode(methodBinding.getMethodDeclaration().getKey()), then it works. The javadoc tells "<li>method - a <code>MethodDeclaration</code> </li>" and "for parameterized or raw method bindings, the declaring node is that of the corresponding generic method." Although the isEnum() is neither a parameterized nor a generic method, I would expect that #findDeclaringNode(..) does the getMethodDeclaration() for me. The speciality of Object#getClass() does not seem to be the issue, since foo(ArrayList<String> as) { boolean b = as.isEmpty(); } also does not work.
Not clear if we want to change this since no AST node exists for capture binding. A workaround exists as described in comment 1 (use getMethodDeclaration()). Will reconsider post 3.2.
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.