1

in Java, I want to know if there is a way to get the jdk version where a class have been added, I want a function that outputs "14" when I put in argument the RecordComponent class (java.lang.reflect.RecordComponent).
ArrayList outputs "7" etc

Is there a way to make something like this ?

Ayfri
  • 570
  • 1
  • 4
  • 24

1 Answers1

1

The information is stored in the @since tag in the javadoc of the class.

To get this information for a specific class you could use the package jdk.javadoc.doclet

scramados
  • 38
  • 6
  • Okay but I have to do this in runtime, not with a command in a terminal, is there a way to do this so ? – Ayfri May 12 '20 at 06:56
  • As explained in: https://stackoverflow.com/a/15312267/5948314 The class does not contain comments. This makes it very difficult to acces them runtime. The easiest solution is probably to scrape the [javadoc](https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/reflect/RecordComponent.html) – scramados May 12 '20 at 08:11