Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit25f829b

Browse files
committed
7903582: jdis incorrectly processes a class compiled with the --enable-preview option
1 parent31cede0 commit25f829b

File tree

7 files changed

+65
-41
lines changed

7 files changed

+65
-41
lines changed

‎maven/mvngen.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
#####################################################################################################
4-
# Symlinks are forbidden in openjdk project, thus we generate them on the flytogehter with pom.xml #
4+
# Symlinks are forbidden in openjdk project, thus we generate them on the flytogether with pom.xml #
55
#####################################################################################################
66

77
set -eo pipefail

‎src/org/openjdk/asmtools/common/structure/CFVersion.java‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ public class CFVersion {
2929
/**
3030
* Default versions of class file
3131
*/
32-
publicstaticfinalshortDEFAULT_MAJOR_VERSION =45;
33-
publicstaticfinalshortDEFAULT_MINOR_VERSION =3;
34-
publicstaticfinalshortDEFAULT_MODULE_MAJOR_VERSION =53;
35-
publicstaticfinalshortDEFAULT_MODULE_MINOR_VERSION =0;
36-
publicstaticfinalshortUNDEFINED_VERSION = -1;
32+
publicstaticfinalintDEFAULT_MAJOR_VERSION =45;
33+
publicstaticfinalintDEFAULT_MINOR_VERSION =3;
34+
publicstaticfinalintDEFAULT_MODULE_MAJOR_VERSION =53;
35+
publicstaticfinalintDEFAULT_MODULE_MINOR_VERSION =0;
36+
publicstaticfinalintUNDEFINED_VERSION = -1;
3737
/* The version of a class file since which the compact format of stack map is necessary */
3838
publicstaticfinalintSPLIT_VERIFIER_CFV =50;
3939

40-
privateshortmajor_version;
41-
privateshortminor_version;
40+
privateintmajor_version;
41+
privateintminor_version;
4242

43-
privateshortthreshold_major_version;
44-
privateshortthreshold_minor_version;
43+
privateintthreshold_major_version;
44+
privateintthreshold_minor_version;
4545

4646
privatebooleanfrozen;
4747

@@ -57,7 +57,7 @@ public CFVersion() {
5757
threshold_minor_version =UNDEFINED_VERSION;
5858
}
5959

60-
publicCFVersion(shortmajor_version,shortminor_version) {
60+
publicCFVersion(intmajor_version,intminor_version) {
6161
frozen =false;
6262
this.major_version =major_version;
6363
this.minor_version =minor_version;
@@ -68,19 +68,19 @@ public CFVersion setFrozen(boolean frozen) {
6868
returnthis;
6969
}
7070

71-
publicCFVersionsetThreshold(shortmajor_version,shortminor_version) {
71+
publicCFVersionsetThreshold(intmajor_version,intminor_version) {
7272
this.threshold_major_version =major_version;
7373
this.threshold_minor_version =minor_version;
7474
returnthis;
7575
}
7676

77-
publicCFVersionsetVersion(shortmajor_version,shortminor_version) {
77+
publicCFVersionsetVersion(intmajor_version,intminor_version) {
7878
this.major_version =major_version;
7979
this.minor_version =minor_version;
8080
returnthis;
8181
}
8282

83-
publicCFVersionsetFileVersion(shortmajor_version,shortminor_version) {
83+
publicCFVersionsetFileVersion(intmajor_version,intminor_version) {
8484
if (isSet() &&isFrozen()) {
8585
if (isThresholdSet()) {
8686
if ((major_version <threshold_major_version) ||
@@ -97,13 +97,13 @@ public CFVersion setFileVersion(short major_version, short minor_version) {
9797
}
9898

9999

100-
publicCFVersionsetMajorVersion(shortmajor_version) {
100+
publicCFVersionsetMajorVersion(intmajor_version) {
101101
if (!frozen)
102102
this.major_version =major_version;
103103
returnthis;
104104
}
105105

106-
publicCFVersionsetMinorVersion(shortminor_version) {
106+
publicCFVersionsetMinorVersion(intminor_version) {
107107
if (!frozen)this.minor_version =minor_version;
108108
returnthis;
109109
}
@@ -172,11 +172,11 @@ public static CFVersion copyOf(CFVersion cfv) {
172172
returncfVersion;
173173
}
174174

175-
publicshortminor_version() {
176-
returnthis.minor_version;
175+
publicintminor_version() {
176+
returnthis.minor_version;
177177
}
178178

179-
publicshortmajor_version() {
179+
publicintmajor_version() {
180180
returnthis.major_version;
181181
}
182182
}

‎src/org/openjdk/asmtools/jasm/Main.java‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
packageorg.openjdk.asmtools.jasm;
2424

25+
importorg.openjdk.asmtools.asmutils.Pair;
2526
importorg.openjdk.asmtools.common.inputs.FileInput;
2627
importorg.openjdk.asmtools.common.inputs.ToolInput;
2728
importorg.openjdk.asmtools.common.outputs.PrintWriterOutput;
@@ -236,13 +237,25 @@ protected void parseArgs(String... argv) {
236237
if (versionsThreshold.length !=2 ||versionsUpdate.length !=2) {
237238
thrownewNumberFormatException();
238239
}
239-
cfv.setThreshold(Short.parseShort(versionsThreshold[0]),Short.parseShort(versionsThreshold[1])).
240-
setVersion(Short.parseShort(versionsUpdate[0]),Short.parseShort(versionsUpdate[1])).
241-
setByParameter(true).setFrozen(true);
240+
Pair<Integer,Integer>versionsPair =newPair<>(Integer.parseInt(versionsThreshold[0]),
241+
Integer.parseInt(versionsThreshold[1]));
242+
if(versionsPair.second >0xFFFF ||versionsPair.first >0xFFFF ) {
243+
thrownewNumberFormatException();
244+
}
245+
cfv.setThreshold(versionsPair.first,versionsPair.second);
246+
versionsPair =newPair<>(Integer.parseInt(versionsUpdate[0]),Integer.parseInt(versionsUpdate[1]));
247+
if(versionsPair.second >0xFFFF ||versionsPair.first >0xFFFF ) {
248+
thrownewNumberFormatException();
249+
}
250+
cfv.setVersion(versionsPair.first,versionsPair.second).setByParameter(true).setFrozen(true);
242251
}else {
243252
String[]versions =cfvArg.split("[.:]+",2);
244253
if (versions.length ==2) {
245-
cfv.setVersion(Short.parseShort(versions[0]),Short.parseShort(versions[1])).
254+
Pair<Integer,Integer>versionsPair =newPair<>(Integer.parseInt(versions[0]),Integer.parseInt(versions[1]));
255+
if(versionsPair.second >0xFFFF ||versionsPair.first >0xFFFF ) {
256+
thrownewNumberFormatException();
257+
}
258+
cfv.setVersion(Integer.parseInt(versions[0]),Integer.parseInt(versions[1])).
246259
setByParameter(true).setFrozen(frozenCFV);
247260
}else {
248261
thrownewNumberFormatException();
@@ -253,7 +266,6 @@ protected void parseArgs(String... argv) {
253266
environment.error("err.invalid_threshold_major_minor_param");
254267
}else {
255268
environment.error("err.invalid_major_minor_param");
256-
257269
}
258270
usage();
259271
thrownewIllegalArgumentException();

‎src/org/openjdk/asmtools/jasm/Parser.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ public int getPosition() {
121121
}
122122

123123
privatevoidparseVersion() {
124-
shortmajorVersion,minorVersion;
124+
intmajorVersion,minorVersion;
125125
if (scanner.token ==Token.VERSION) {
126126
scanner.scan();
127127
if (scanner.token ==Token.INTVAL) {
128-
majorVersion =(short)scanner.intValue;
128+
majorVersion =scanner.intValue;
129129
scanner.scan();
130130
if (scanner.token ==Token.COLON) {
131131
scanner.scan();
132132
if (scanner.token ==Token.INTVAL) {
133-
minorVersion =(short)scanner.intValue;
133+
minorVersion =scanner.intValue;
134134
classData.cfv.setFileVersion(majorVersion,minorVersion);
135135
scanner.scan();
136136
traceMethodInfoLn("parseVersion: " +classData.cfv.asString());
@@ -1546,8 +1546,8 @@ private void parseClass(int mod) throws IOException {
15461546
}
15471547
}else {
15481548
if (classData.cfv.isSet() &&classData.cfv.isSetByParameter() &&classData.cfv.isFrozen()) {
1549-
shortminor =classData.cfv.minor_version();
1550-
shortmajor =classData.cfv.major_version();
1549+
intminor =classData.cfv.minor_version();
1550+
intmajor =classData.cfv.major_version();
15511551
Stringversion =classData.cfv.asString();
15521552
Stringoption =classData.cfv.isThresholdSet() ?classData.cfv.asThresholdString() :classData.cfv.asString();
15531553
parseVersion();

‎src/org/openjdk/asmtools/jasm/i18n.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ info.opt.fixcv.full=\
3939
err.cv_requires_arg=-cv option requires the argument <major.minor>
4040
err.fix_cv_requires_arg=-fixcv option requires the argument either <major.minor> or <major.minor>-<major.minor>
4141
err.invalid_major_minor_param=Invalid parameter <major.minor>
42-
err.invalid_threshold_major_minor_param=Invalid parameter\"-fixvc '{<major.minor>-}'<major.minor>\"
42+
err.invalid_threshold_major_minor_param=Invalid parameter\"-fixcv '{<major.minor>-}'<major.minor>\"
4343
err.invalid_option=Invalid option: {0}
4444
err.byte.limit=Unspecified byte-limit
4545

‎src/org/openjdk/asmtools/jcoder/Main.java‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
packageorg.openjdk.asmtools.jcoder;
2424

25+
importorg.openjdk.asmtools.asmutils.Pair;
2526
importorg.openjdk.asmtools.common.inputs.FileInput;
2627
importorg.openjdk.asmtools.common.inputs.ToolInput;
2728
importorg.openjdk.asmtools.common.outputs.PrintWriterOutput;
@@ -216,31 +217,42 @@ protected void parseArgs(String... argv) {
216217
usage();
217218
thrownewIllegalArgumentException();
218219
}
220+
StringcfvArg =argv[++i];
221+
booleanwithThreshold =cfvArg.contains("-");
219222
try {
220-
221-
StringcfvArg =argv[++i];
222-
if (cfvArg.contains("-")) {
223+
if (withThreshold) {
223224
String[]versions =cfvArg.split("-",2);
224225
String[]versionsThreshold =versions[0].split("[.:]+",2);
225226
String[]versionsUpdate =versions[1].split("[.:]+",2);
226227
if (versionsThreshold.length !=2 ||versionsUpdate.length !=2) {
227228
thrownewNumberFormatException();
228229
}
229-
environment.cfv.setThreshold(Short.parseShort(versionsThreshold[0]),Short.parseShort(versionsThreshold[1])).
230-
setVersion(Short.parseShort(versionsUpdate[0]),Short.parseShort(versionsUpdate[1])).
231-
setByParameter(true).setFrozen(true);
232-
230+
Pair<Integer,Integer>versionsPair =newPair<>(Integer.parseInt(versionsThreshold[0]),
231+
Integer.parseInt(versionsThreshold[1]));
232+
if(versionsPair.second >0xFFFF ||versionsPair.first >0xFFFF ) {
233+
thrownewNumberFormatException();
234+
}
235+
environment.cfv.setThreshold(versionsPair.first,versionsPair.second);
236+
versionsPair =newPair<>(Integer.parseInt(versionsUpdate[0]),Integer.parseInt(versionsUpdate[1]));
237+
if(versionsPair.second >0xFFFF ||versionsPair.first >0xFFFF ) {
238+
thrownewNumberFormatException();
239+
}
240+
environment.cfv.setVersion(versionsPair.first,versionsPair.second).setByParameter(true).setFrozen(true);
233241
}else {
234242
String[]versions =cfvArg.split("[.:]+",2);
235243
if (versions.length ==2) {
236-
environment.cfv.setVersion(Short.parseShort(versions[0]),Short.parseShort(versions[1])).
244+
Pair<Integer,Integer>versionsPair =newPair<>(Integer.parseInt(versions[0]),Integer.parseInt(versions[1]));
245+
if(versionsPair.second >0xFFFF ||versionsPair.first >0xFFFF ) {
246+
thrownewNumberFormatException();
247+
}
248+
environment.cfv.setVersion(Integer.parseInt(versions[0]),Integer.parseInt(versions[1])).
237249
setByParameter(true).setFrozen(true);
238250
}else {
239251
thrownewNumberFormatException();
240252
}
241253
}
242254
}catch (PatternSyntaxException |NumberFormatExceptionexception) {
243-
environment.error("err.invalid_threshold_major_minor_param");
255+
environment.error("err.invalid_threshold_major_minor_param");
244256
usage();
245257
thrownewIllegalArgumentException();
246258
}

‎src/org/openjdk/asmtools/jdis/ClassData.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ public void read(final DataInputStream in, final Path src) throws IOException {
285285
thrownewClassCastException("wrong magic: " +HexUtils.toHex(magic) +", expected " +HexUtils.toHex(JAVA_MAGIC));
286286
}
287287

288-
cfVersion.setMinorVersion((short)in.readUnsignedShort());
289-
cfVersion.setMajorVersion((short)in.readUnsignedShort());
288+
cfVersion.setMinorVersion(in.readUnsignedShort());
289+
cfVersion.setMajorVersion(in.readUnsignedShort());
290290

291291
// Read the constant pool
292292
pool.read(in);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp