1 /*
 2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 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
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 package jdk.experimental.bytecode;
25 
26 import java.util.EnumSet;
27 
28 public enum Flag {
29     ACC_PUBLIC(0x0001),
30     ACC_PROTECTED(0x0004),
31     ACC_PRIVATE(0x0002),
32     ACC_IDENTITY(0x0020),
33     ACC_INTERFACE(0x0200),
34     ACC_ENUM(0x4000),
35     ACC_ANNOTATION(0x2000),
36     ACC_SUPER(0x0020),
37     ACC_ABSTRACT(0x0400),
38     ACC_VOLATILE(0x0040),
39     ACC_TRANSIENT(0x0080),
40     ACC_SYNTHETIC(0x1000),
41     ACC_STATIC(0x0008),
42     ACC_FINAL(0x0010),
43     ACC_SYNCHRONIZED(0x0020),
44     ACC_BRIDGE(0x0040),
45     ACC_VARARGS(0x0080),
46     ACC_NATIVE(0x0100),
47     ACC_INLINE(0x0100),
48     ACC_STRICT(0x0800);
49 
50     public int flag;
51 
52     Flag(int flag) {
53         this.flag = flag;
54     }
55 
56     static Flag[] parse(int flagsMask) {
57         EnumSet<Flag> flags = EnumSet.noneOf(Flag.class);
58         for (Flag f : Flag.values()) {
59             if ((f.flag & flagsMask) != 0) {
60                 flags.add(f);
61             }
62         }
63         return flags.stream().toArray(Flag[]::new);
64     }
65 }