1

As of Java 10 or Java 11, is there any built-in support yet for identifying member variables as properties instead of having my IDE auto-generate getter/setter accessor methods in JavaBeans style?

Kotlin identifies properties by declaring them as var or val, read-write or read-only respectively. Objective-C was able to auto-synthesize the accessor methods. Any such support in Java yet?

I am looking for built-in features in Java, not external solutions such as Project Lombok.

I am asking for an update to: Java and C#-like properties.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • 1
    IMHO, this could have been a better question to the *jdk-dev* mailing list than SO. Yet to understand better, what is the usefulness you're trying to derive here? Additionally from the [JDK10 release notes](https://www.oracle.com/technetwork/java/javase/10u-relnotes-4108739.html) and [early access release notes of JDK11](http://jdk.java.net/11/release-notes) doesn't seem like a feature introduced yet. – Naman Jul 19 '18 at 03:26
  • 1
    I could find this interesting old blog from Stephen on searching further - [No properties in the Java language](http://blog.joda.org/2014/11/no-properties-in-java-language.html). On the other hand, one could always argue [why its important to write getters and setters](https://stackoverflow.com/questions/1568091)! – Naman Jul 19 '18 at 03:34
  • 2
    @nullpointer The usefulness I am trying to derive is to simply document whether a [long-standing problem of lack of property support in Java](http://blog.ringerc.id.au/2010/08/java-and-properties.html) has been remedied. Solutions have been discussed in the past by major Java figures. Kotlin, at least, showed an implementation for the JVM. The [Tutorial page on Properties](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) is out-of-date after Java 8. Much has been changing in Java 9-10-11. So I am asking for an update on the status. – Basil Bourque Jul 19 '18 at 05:06
  • Interesting that the same issue asked eight years ago, [*Java and C#-like properties*](https://stackoverflow.com/q/2312662/642706), earned 16 up-votes and no down-votes, yet mine here garners a pair of down-votes. Stack Overflow is a capricious arena. – Basil Bourque Jul 19 '18 at 05:08
  • 1
    Just to note, not aware of what SO policies in past were, but then there must have been a thought on what they've been framed currently. Ans, since you're just asking for an update, trying to post on the existing thread, should've been the first thing to look for. Anyway, the question as I said earlier doesn't really make sense to post it here and would have been better off at the mailing list. – Naman Jul 19 '18 at 19:00
  • 2
    The [Tutorial page on Properties](https://docs.oracle.com/javase/tutorial/essential/environment/properties.html) is **not** “out-of-date after Java 8”. It is a tutorial about the Java class named `Properties` and always was; it was never intended to talk about the kind of properties your question is about. – Holger Jul 20 '18 at 10:43
  • If this Question were not closed, I would have posted an Answer about the new `record` feature in Java 16. – Basil Bourque Apr 14 '21 at 21:01

1 Answers1

2

Any such support in Java yet?

The answer is No, as of the time of writing.

Furthermore, I have seen no clear signs that property support is on the horizon; e.g. no JEPs that mention this (unless I missed something).

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • 4
    As to your implication that people should not answer because it makes it hard to clear up poorly written or poorly researched or whatever questions. The solution to that is to campaign for a better way to clean up poor questions **irrespective of the answers**. – Stephen C Jul 19 '18 at 03:41