Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/share/classes/jdk/internal/module/ModuleResolution.java
41159 views
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. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package jdk.internal.module;
27
28
import java.lang.module.ModuleReference;
29
import static jdk.internal.module.ClassFileConstants.*;
30
31
/**
32
* Represents the Module Resolution flags.
33
*/
34
public final class ModuleResolution {
35
36
final int value;
37
38
ModuleResolution(int value) {
39
this.value = value;
40
}
41
42
public int value() {
43
return value;
44
}
45
46
public static ModuleResolution empty() {
47
return new ModuleResolution(0);
48
}
49
50
public boolean doNotResolveByDefault() {
51
return (value & DO_NOT_RESOLVE_BY_DEFAULT) != 0;
52
}
53
54
public boolean hasDeprecatedWarning() {
55
return (value & WARN_DEPRECATED) != 0;
56
}
57
58
public boolean hasDeprecatedForRemovalWarning() {
59
return (value & WARN_DEPRECATED_FOR_REMOVAL) != 0;
60
}
61
62
public boolean hasIncubatingWarning() {
63
return (value & WARN_INCUBATING) != 0;
64
}
65
66
public ModuleResolution withDoNotResolveByDefault() {
67
return new ModuleResolution(value | DO_NOT_RESOLVE_BY_DEFAULT);
68
}
69
70
public ModuleResolution withDeprecated() {
71
if ((value & (WARN_DEPRECATED_FOR_REMOVAL | WARN_INCUBATING)) != 0)
72
throw new InternalError("cannot add deprecated to " + value);
73
return new ModuleResolution(value | WARN_DEPRECATED);
74
}
75
76
public ModuleResolution withDeprecatedForRemoval() {
77
if ((value & (WARN_DEPRECATED | WARN_INCUBATING)) != 0)
78
throw new InternalError("cannot add deprecated for removal to " + value);
79
return new ModuleResolution(value | WARN_DEPRECATED_FOR_REMOVAL);
80
}
81
82
public ModuleResolution withIncubating() {
83
if ((value & (WARN_DEPRECATED | WARN_DEPRECATED_FOR_REMOVAL)) != 0)
84
throw new InternalError("cannot add incubating to " + value);
85
return new ModuleResolution(value | WARN_INCUBATING);
86
}
87
88
public static boolean doNotResolveByDefault(ModuleReference mref) {
89
// get the DO_NOT_RESOLVE_BY_DEFAULT flag, if any
90
if (mref instanceof ModuleReferenceImpl) {
91
ModuleResolution mres = ((ModuleReferenceImpl) mref).moduleResolution();
92
if (mres != null)
93
return mres.doNotResolveByDefault();
94
}
95
96
return false;
97
}
98
99
public static boolean hasIncubatingWarning(ModuleReference mref) {
100
if (mref instanceof ModuleReferenceImpl) {
101
ModuleResolution mres = ((ModuleReferenceImpl) mref).moduleResolution();
102
if (mres != null)
103
return mres.hasIncubatingWarning();
104
}
105
106
return false;
107
}
108
109
@Override
110
public String toString() {
111
return super.toString() + "[value=" + value + "]";
112
}
113
}
114
115