vendredi 16 avril 2021

Is there a way to recognise a Java 16 record's "main" constructor via reflection?

Assuming I have a record like this (or any other record):

record X(int i, int j) {
    X(int i) {
        this(i, 0);
    }
    X() {
        this(0, 0);
    }
    X(String i, String j) {
        this(Integer.parseInt(i), Integer.parseInt(j));
    }
}

Is there a way to find this record's "main" constructor, i.e. the one that is implicitly declared in the RecordHeader?





Aucun commentaire:

Enregistrer un commentaire