1/*
2 * Copyright (c) 2016, 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
24package selectionresolution;
25
26import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
27import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
28import static jdk.internal.org.objectweb.asm.Opcodes.V1_8;
29
30
31class Clazz extends ClassConstruct {
32
33    /**
34     * Construct a Class
35     * @param name Name of Class
36     * @param access Access for the Class
37     */
38    public Clazz(String name, int access, int index) {
39        this(name, null, access, V1_8, index, new String[] { });
40    }
41
42    /**
43     * Construct a Class
44     * @param name Name of Class
45     * @param extending Class being extended
46     * @param access Access for the Class
47     */
48    public Clazz(String name, String extending, int access, int index) {
49        this(name, extending, access, V1_8, index, new String[] { });
50    }
51
52    /**
53     * Construct a Class
54     * @param name Name of Class
55     * @param extending Class being extended
56     * @param access access for the Class
57     * @param implementing Interfaces implemented
58     */
59    public Clazz(String name, String extending, int access, int index, String... implementing) {
60        this(name, extending, access, V1_8, index, implementing);
61    }
62
63    /**
64     * Construct a Class
65     * @param name Name of Class
66     * @param extending Class being extended
67     * @param access Access for the Class
68     * @param classFileVersion Class file version
69     * @param implementing Interfaces implemented
70     */
71    public Clazz(String name, String extending, int access, int classFileVersion, int index, String... implementing) {
72        super(name, extending == null ? "java/lang/Object" : extending, access + ACC_SUPER, classFileVersion, index, implementing);
73        // Add the default constructor
74        addMethod("<init>", "()V", ACC_PUBLIC).makeConstructor(extending, false);
75    }
76}
77