<i18n dev> RFR: 8268124: Update java.lang to use switch expressions [v3]

Patrick Concannon pconcannon at openjdk.java.net
Thu Jun 3 11:01:06 UTC 2021


On Wed, 2 Jun 2021 16:06:42 GMT, Rémi Forax <forax at openjdk.org> wrote:

>> Patrick Concannon has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8268124: small refactoring; fixed misplaced comment and added missing lambda operator
>
> src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java line 1663:
> 
>> 1661:             case D_TYPE -> mv.visitInsn(Opcodes.DCONST_0);
>> 1662:             case L_TYPE -> mv.visitInsn(Opcodes.ACONST_NULL);
>> 1663:             default -> throw new InternalError("unknown type: " + type);
> 
> perhaps
> 
>   mv.visitInsn(switch(type) { ...

Hi Remi, thanks for the suggestion. I've added that in now. See commit a8706b0

> src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java line 278:
> 
>> 276:     private static boolean isObjectMethod(Method m) {
>> 277:         return switch (m.getName()) {
>> 278:             case "toString" -> (m.getReturnType() == String.class
> 
> the extra parenthesis are not needed

Parenthesis removed, as suggested. See a8706b0

> src/java.base/share/classes/java/lang/runtime/ObjectMethods.java line 366:
> 
>> 364:             }
>> 365:             default -> throw new IllegalArgumentException(methodName);
>> 366:         };
> 
> I thinki it's simpler to have something like that
> 
>   var handle = switch(methodName) {
>     ...
>   };
>   return methodType != null ? new ConstantCallSite(handle) : handle;

I think that looks better. I've made that change now. See a8706b0

-------------

PR: https://git.openjdk.java.net/jdk/pull/4312


More information about the i18n-dev mailing list