RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v8]

Aggelos Biboudis abimpoudis at openjdk.org
Thu Oct 5 11:23:15 UTC 2023


On Thu, 5 Oct 2023 09:58:52 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Declutter Lower.visitTypeTest
>
> src/java.base/share/classes/java/lang/runtime/ExactnessMethods.java line 35:
> 
>> 33:  * @since 22
>> 34:  */
>> 35: final public class ExactnessMethods {
> 
> I think it should be `public final` (order of modifier)

Done

> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 230:
> 
>> 228:                          if (selectorType.equals(Object.class)) {
>> 229:                             currentTest = INSTANCEOF_CHECK;
>> 230:                             if (currentLabelClass.isAssignableFrom(byte.class)) { testLabel = Byte.class; }
> 
> I assume here you want to box the primitive, right? If that's the case, consider using the JDK class `sun.invoke.util.Wrapper`, which has a factory `forBasicType` that takes a class. From there you can get the boxed type easily, in a single line.

Perfect! Exactly what I needed.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1347256678
PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1347256224


More information about the compiler-dev mailing list