Bug 536277 - Eclipse compilation OK, but jdk1.7.0_80 compilation error: cannot find symbol
Summary: Eclipse compilation OK, but jdk1.7.0_80 compilation error: cannot find symbol
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7.3   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-26 02:33 EDT by Kirill Golovin CLA
Modified: 2022-07-24 02:24 EDT (History)
2 users (show)

See Also:


Attachments
Test cource code (2.81 KB, application/zip)
2018-06-26 02:33 EDT, Kirill Golovin CLA
no flags Details
Test cource code for OK compilation (2.80 KB, application/zip)
2018-06-26 02:34 EDT, Kirill Golovin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kirill Golovin CLA 2018-06-26 02:33:26 EDT
Created attachment 274611 [details]
Test cource code

Hello,
i have small problem in my work project - i development and debug in Eclipse successfully, but i have compilation error in JDK 1.7.

I create simple test - src_error.zip

C:\Java\Java64\jdk1.7.0_80\bin\javac.exe ./src/com/bercut/test/Main.java
.\src\com\bercut\test\Main.java:8: error: cannot find symbol
    class OperationInfo implements Comparator<MessageInfo> {
                                              ^
  symbol:   class MessageInfo
  location: class Main
1 error


Problem in imports - "import com.bercut.test.Main.OperationInfo.MessageInfo;"

Compilation JDK 1.7 is OK after i make change:
1) Delete imports - delete string "import com.bercut.test.Main.OperationInfo.MessageInfo;"
2) Change declaration "class OperationInfo" to "class OperationInfo implements Comparator<OperationInfo.MessageInfo>"

JDT always compiles successfully.

What is the reason for the different results of the compilers (JDK1.7 and JDT)?
Comment 1 Kirill Golovin CLA 2018-06-26 02:34:16 EDT
Created attachment 274612 [details]
Test cource code for OK compilation
Comment 2 Stephan Herrmann CLA 2018-06-30 14:03:38 EDT
From JLS §6.3:

"The scope of a declaration is the region of the program within which the entity declared by the declaration can be referred to using a simple name, provided it is not shadowed (§6.4.1)."

"The scope of a declaration of a member m declared in or inherited by a class type C (§8.1.6) is the entire body of C, including any nested type declarations."

From this, the simple name "MessageInfo" is valid throughout the body of class OperationInfo.

Question is, whether the super interface reference is "inside" or "outside" class OperationInfo. One should normally assume that the "body" starts at the "{" and not before. OTOH, I vaguely recall that super type references do need to be treated specially in some situations. Will have to dig out the use case before we can make a call.
Comment 3 Manoj N Palat CLA 2019-02-11 04:16:43 EST
Bulk move out of 4.11
Comment 4 Manoj N Palat CLA 2019-08-27 02:02:18 EDT
Bulk move to 4.14
Comment 5 Stephan Herrmann CLA 2019-11-17 16:09:16 EST
Bulk move of unassigned bugs to 4.15
Comment 6 Stephan Herrmann CLA 2020-02-27 18:50:03 EST
Bulk move to 4.16
Comment 7 Stephan Herrmann CLA 2020-05-18 18:45:56 EDT
Bulk move of unassigned bugs to 4.17
Comment 8 Eclipse Genie CLA 2022-07-24 02:24:56 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.