src/jdk.internal.vm.compiler/share/classes/org.graalvm.graphio/src/org/graalvm/graphio/DefaultGraphTypes.java
changeset 58533 46b0b7fe255c
parent 52910 583fd71c47d6
equal deleted inserted replaced
58532:b4f2e13d20ea 58533:46b0b7fe255c
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    28     static final GraphTypes DEFAULT = new DefaultGraphTypes();
    28     static final GraphTypes DEFAULT = new DefaultGraphTypes();
    29 
    29 
    30     private DefaultGraphTypes() {
    30     private DefaultGraphTypes() {
    31     }
    31     }
    32 
    32 
       
    33     @SuppressWarnings("unchecked")
    33     @Override
    34     @Override
    34     public Class<?> enumClass(Object enumValue) {
    35     public Class<?> enumClass(Object enumValue) {
    35         if (enumValue instanceof Enum<?>) {
    36         if (enumValue instanceof Enum<?>) {
    36             return enumValue.getClass();
    37             // check that the enum class is not actually an anonymous subclass:
       
    38             Class<? extends Enum<?>> enumClass = (Class<? extends Enum<?>>) enumValue.getClass();
       
    39             Enum<?>[] constants = enumClass.getEnumConstants();
       
    40             if (constants == null && enumClass.isAnonymousClass()) {
       
    41                 enumClass = (Class<? extends Enum<?>>) enumClass.getSuperclass();
       
    42             }
       
    43             return enumClass;
    37         }
    44         }
    38         return null;
    45         return null;
    39     }
    46     }
    40 
    47 
    41     @Override
    48     @Override