Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/jpda/StratumUtils.java
41161 views
1
/*
2
* Copyright (c) 2011, 2018, 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 vm.mlvm.share.jpda;
25
26
import nsk.share.ArgumentParser;
27
import vm.mlvm.share.Env;
28
29
import com.sun.jdi.AbsentInformationException;
30
import com.sun.jdi.Location;
31
import com.sun.jdi.ObjectReference;
32
import com.sun.jdi.ReferenceType;
33
import com.sun.jdi.StackFrame;
34
35
public class StratumUtils {
36
37
public static boolean checkStratum(Location location, StratumInfo si) throws AbsentInformationException {
38
// Check stratum information
39
try {
40
Env.traceVerbose(String.format("Stratum [%s]: required=[%s:%d]", si.stratum, si.stratumSourceName, si.stratumSourceLine));
41
Env.traceVerbose(String.format("Default stratum: location=[%s:%d]", location.sourceName(), location.lineNumber()));
42
43
String stratumSourceName = location.sourceName(si.stratum);
44
int stratumSourceLine = location.lineNumber(si.stratum);
45
String stratumInfo = String.format("actual=[%s:%d]", stratumSourceName, stratumSourceLine);
46
47
if (stratumSourceName.equals(si.stratumSourceName) && stratumSourceLine == si.stratumSourceLine) {
48
Env.traceVerbose("Stratum matches: " + stratumInfo);
49
return true;
50
} else {
51
Env.complain("Stratum mismatch: " + stratumInfo);
52
return false;
53
}
54
} catch (AbsentInformationException e) {
55
Env.complain(e, "Strata information is absent. Available strata: " + getStrataStr(location.declaringType()));
56
57
return false;
58
}
59
}
60
61
public static StratumInfo parseStratumInfo(String stratumInfo) throws Exception {
62
int sourceNamePos = stratumInfo.indexOf('=');
63
int sourceLinePos = stratumInfo.indexOf(':');
64
65
if (sourceNamePos == -1 || sourceLinePos == -1 || sourceNamePos >= sourceLinePos) {
66
throw new ArgumentParser.BadOption("Wrong syntax of stratum information: [" + stratumInfo + "]");
67
}
68
69
return new StratumInfo(
70
stratumInfo.substring(0, sourceNamePos),
71
stratumInfo.substring(sourceNamePos + 1, sourceLinePos),
72
Integer.parseInt(stratumInfo.substring(sourceLinePos + 1)));
73
}
74
75
public static String getStrataStr(StackFrame sf) {
76
ObjectReference thisObject = sf.thisObject();
77
if (thisObject == null)
78
return "(no strata)";
79
return StratumUtils.getStrataStr(thisObject.referenceType());
80
}
81
82
public static String getStrataStr(ReferenceType ref) {
83
return ref.availableStrata() + " (" + ref + ")";
84
}
85
}
86
87