Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 46788 Details for
Bug 151787
[compiler] compiler allows assignment to final field in constructor other than through 'this'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
final field initialization test cases
FinalBug.java (text/plain), 1.73 KB, created by
Christopher Unkel
on 2006-07-25 19:31:47 EDT
(
hide
)
Description:
final field initialization test cases
Filename:
MIME Type:
Creator:
Christopher Unkel
Created:
2006-07-25 19:31:47 EDT
Size:
1.73 KB
patch
obsolete
>/* > * Created on Jul 25, 2006 > * > * To change the template for this generated file go to > * Window - Preferences - Java - Code Generation - Code and Comments > */ >package cu.misc; > >public class FinalBug { > // correctly passes compilation > static class Test1 { > private final Object o; > > Test1() { > o = new Object(); > } > } > > // correctly passes compilation > static class Test2 { > private final Object o; > > Test2() { > this.o = new Object(); > } > } > > // correctly fails compilation > static class Test3 { > private final Object o; > > Test3() { > System.out.println(o); // illegal; o is not definitely assigned > o = new Object(); > } > } > > // correctly passes compilation > static class Test4 { > private final Object o; > > Test4() { > System.out.println(this.o); // legal > o = new Object(); > } > } > > // incorrectly passes compilation > static class Test5 { > private final Object o; > > Test5() { > Test5 other = this; > other.o = new Object(); // illegal! other.o is not assignable > } // error: this.o is not definitely assigned > } > > // flags wrong statement as error > static class Test6 { > private final Object o; > static Test6 initing; > > Test6() { > initing = this; > System.out.println("greetings"); > Test6 other = initing; > other.o = new Object(); // illegal! other.o is not assignable > o = new Object(); // legal > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 151787
: 46788 |
62485
|
62503
|
62551