hg: amber/amber: sync the reflection API for records with the specification

Remi Forax forax at univ-mlv.fr
Thu Jun 27 06:00:10 UTC 2019


Hi Vicente,
two remarks,
as a user, i will want to get the component name without doing reflection on it, by example to use method handles,
so i think that in term of API, there should be a public method getRecordComponentNames() too.

now in term of implementation of getRecordAccessors(), you have a bug in it,
the loop mix the enhanced for with a supplementary index but you don't increment it

int i = 0;
for (String componentName : componentNames) {
  result[i] = getMethod(componentName);   // oops
}

Here using the enhanced for is not a good idea, it should be used if you don't need an index, otherwise in the generated bytecodes you have two indexes,
so the code should be

for (int i = 0; i < componentNames.lengh; i++) {
  String componentName = componentNames[i];
  result[i] = getMethod(componentName);   // ok
}

regards,
Rémi

----- Mail original -----
> De: "Vicente Romero" <vicente.romero at oracle.com>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Jeudi 27 Juin 2019 02:10:25
> Objet: hg: amber/amber: sync the reflection API for records with the specification

> Changeset: 7241fb1920dc
> Author:    vromero
> Date:      2019-06-26 20:09 -0400
> URL:       http://hg.openjdk.java.net/amber/amber/rev/7241fb1920dc
> 
> sync the reflection API for records with the specification
> 
> ! make/hotspot/symbols/symbols-unix
> ! src/hotspot/share/include/jvm.h
> ! src/hotspot/share/prims/jvm.cpp
> ! src/java.base/share/classes/java/lang/Class.java
> ! src/java.base/share/native/libjava/Class.c


More information about the amber-dev mailing list