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

Commit54a6b39

Browse files
committed
7903791: jasm: incorrectly parsed static argument list
1 parente586cb9 commit54a6b39

File tree

31 files changed

+804
-45
lines changed

31 files changed

+804
-45
lines changed

‎build/productinfo.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ PRODUCT_NAME =asmtools
2727
PRODUCT_JAR_NAME =asmtools.jar
2828
PRODUCT_VERSION =9.0
2929
PRODUCT_MILESTONE =ea
30-
PRODUCT_BUILDNUMBER =06
30+
PRODUCT_BUILDNUMBER =07
3131
PRODUCT_NAME_LONG =Java Assembler Tools

‎src/org/openjdk/asmtools/common/ToolLogger.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public enum EMessageFormatter {
167167
}
168168

169169
publicStringapply(EMessageKindkind,Stringname,Stringformat,Object...args) {
170-
returntriFunc.apply(kind,name,format(format,args));
170+
return(format ==null ||name ==null) ?"" :triFunc.apply(kind,name,format(format,args));
171171
}
172172

173173
publicStringapply(Stringname,Messagemessage) {

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

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

25+
importstaticorg.openjdk.asmtools.common.structure.ClassFileContext.ORDINARY;
2526
importstaticorg.openjdk.asmtools.common.structure.ClassFileContext.VALUE_OBJECTS;
2627

2728
/*
@@ -57,6 +58,7 @@ public CFVersion() {
5758
setVersion(UNDEFINED_VERSION,UNDEFINED_VERSION);
5859
threshold_major_version =UNDEFINED_VERSION;
5960
threshold_minor_version =UNDEFINED_VERSION;
61+
EModifier.setGlobalContext(ORDINARY);
6062
isSetByParameter =false;
6163
frozen =false;
6264
}
@@ -66,6 +68,11 @@ public CFVersion(CFVersion other) {
6668
threshold_major_version =other.threshold_major_version;
6769
threshold_minor_version =other.threshold_minor_version;
6870
this.isSetByParameter =other.isSetByParameter;
71+
if (isValueObjectContext()) {
72+
EModifier.setGlobalContext(VALUE_OBJECTS);
73+
}else {
74+
EModifier.setGlobalContext(ORDINARY);
75+
}
6976
this.frozen =other.frozen;
7077
}
7178

@@ -74,6 +81,8 @@ public CFVersion(int major_version, int minor_version) {
7481
this.minor_version =minor_version;
7582
if (isValueObjectContext()) {
7683
EModifier.setGlobalContext(VALUE_OBJECTS);
84+
}else {
85+
EModifier.setGlobalContext(ORDINARY);
7786
}
7887
}
7988

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021,2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021,2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996,2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996,2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
2323
packageorg.openjdk.asmtools.jasm;
2424

2525
importjava.io.IOException;
26+
importjava.util.ArrayList;
2627
importjava.util.List;
2728
importjava.util.Objects;
2829
importjava.util.stream.Collectors;
@@ -44,7 +45,7 @@ public BootstrapMethodData(ConstCell bsmHandle, List<ConstCell<?>> arguments) {
4445
publicBootstrapMethodData(intmethodAttrIndex) {
4546
super();
4647
this.bootstrapMethodHandle =null;
47-
this.arguments =null;
48+
this.arguments =newArrayList<>();
4849
super.cpIndex =methodAttrIndex;
4950
}
5051

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ private <E extends ConstValue_BootstrapMethod> E visitBsm(BiFunction<BootstrapMe
657657
}
658658
intcpx =scanner.intValue;
659659
scanner.scan();
660-
// Put a placeholder in place of BSM.
660+
// Put a placeholder in place of BSM.
661661
// resolve placeholder after the attributes are scanned.
662662
BootstrapMethodDatabsmData =newBootstrapMethodData(bsmIndex);
663663
obj =ctor.apply(bsmData,parser.pool.getCell(cpx));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ protected Parser(JasmEnvironment environment, CFVersion cfVersion) throws IOExce
108108
this.annotParser =newParseAnnotation(this);
109109
this.instrParser =newParseInstruction(this,cpParser);
110110
this.attributeParser =newParseAttribute(this);
111-
EModifier.setGlobalContext(ClassFileContext.ORDINARY);
112111
this.currentCFV =copyOf(cfVersion);
113112
}
114113

@@ -1009,7 +1008,7 @@ private void parseBootstrapMethodGroup() throws SyntaxError {
10091008
List<Token>expectedToken =List.of(INTVAL);
10101009
intmhIndex =0;
10111010
ConstCell<?>MHCell =null;
1012-
ArrayList<ConstCell<?>>bsm_args =newArrayList<>(256);
1011+
ArrayList<ConstCell<?>>bsm_args =newArrayList<>(10);
10131012
while (true) {
10141013
switch (scanner.token) {
10151014
caseINTVAL -> {
@@ -1038,7 +1037,7 @@ private void parseBootstrapMethodGroup() throws SyntaxError {
10381037
scanner.expect(COLON);
10391038
cpParser.incLBRACE();
10401039
// scan Bootstrap arguments
1041-
bsm_args.clear();
1040+
bsm_args =newArrayList<>(10);
10421041
expectedToken =List.of(CPINDEX,IDENT,CLASS);
10431042
while (true) {
10441043
if (scanner.token.in(CPINDEX,IDENT,CLASS)) {
@@ -1073,6 +1072,7 @@ private void parseBootstrapMethodGroup() throws SyntaxError {
10731072
}
10741073
classData.addBootstrapMethod(newBootstrapMethodData(MHCell,bsm_args));
10751074
MHCell =null;
1075+
bsm_args =newArrayList<>(10);
10761076
expectedToken =List.of(INTVAL,RBRACE);
10771077
}
10781078
caseRBRACE -> {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ protected void jasmPrint(int index, int size) throws IOException {
9292
BootstrapMethodBreakPositions)
9393
);
9494
}
95+
printIndent(PadRight(" ",TABLE_PADDING)).print("{ ");
9596
if (numBsmArgs >0) {
96-
printIndent(PadRight(" ",TABLE_PADDING)).println("{");
97+
println();
9798
incIndent(2);
9899
if (printCPIndex) {
99100
for (inti =0;i <numBsmArgs;i++) {
@@ -119,8 +120,9 @@ protected void jasmPrint(int index, int size) throws IOException {
119120
BootstrapArgumentsBreakPositions));
120121
}
121122
decIndent(2);
122-
printIndent(PadRight(" ",TABLE_PADDING)).println("}");
123+
printIndent(PadRight(" ",TABLE_PADDING));
123124
}
125+
println("}");
124126
if (index <size -1)
125127
println();
126128
}
@@ -186,7 +188,6 @@ protected void tablePrint(int index, int size) throws IOException {
186188
}
187189
}
188190

189-
190191
privateBsmInfogetBsmInfo() {
191192
StringstrBsm;
192193
ConstantPool.Constant<?>cnt =owner.pool.getConst(bsmRef);
@@ -196,13 +197,14 @@ private BsmInfo getBsmInfo() {
196197
strBsm =cpx.stringVal() +";";
197198
}else {
198199
strBsm =owner.environment.getInfo("info.corrupted_bootstrap_method_ref");
199-
if(!printCPIndex) {
200+
if(!printCPIndex) {
200201
strBsm =PadRight("#%d".formatted(bsmRef),CIRCULAR_COMMENT_OFFSET).concat(" // ").concat(strBsm);
201202
}
202203
}
203204
BsmInfobsmInfo =newBsmInfo(strBsm,cpx2Const);
204205
returnbsmInfo;
205206
}
206207

207-
privaterecordBsmInfo(StringstrBsm,ConstantPool.CPX2cpx2Const) {}
208+
privaterecordBsmInfo(StringstrBsm,ConstantPool.CPX2cpx2Const) {
209+
}
208210
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
importorg.openjdk.asmtools.common.DecompilerLogger;
2828
importorg.openjdk.asmtools.common.Environment;
2929
importorg.openjdk.asmtools.common.FormatError;
30+
importorg.openjdk.asmtools.common.SyntaxError;
3031
importorg.openjdk.asmtools.common.inputs.FileInput;
3132
importorg.openjdk.asmtools.common.inputs.ToolInput;
3233
importorg.openjdk.asmtools.common.structure.CFVersion;
@@ -508,7 +509,7 @@ public void print() throws IOException {
508509
for (IOExceptionioe :issues) {
509510
environment.error(ioe);
510511
}
511-
thrownewRuntimeException();
512+
thrownewSyntaxError();
512513
}
513514
}
514515

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,15 +1085,15 @@ public String bsmArgsAsString(BootstrapMethodData bsmData) {
10851085
publicStringbsmArgsAsString(BootstrapMethodDatabsmData,StringLeftBracket,StringRightBracket) {
10861086
StringBuildersb =newStringBuilder();
10871087
intbsmArgsLen =bsmData.bsmArguments.size();
1088+
sb.append(LeftBracket);
10881089
if (bsmArgsLen >0) {
1089-
sb.append(LeftBracket);
10901090
for (inti =0;i <bsmArgsLen;i++) {
10911091
intbsmArgIdx =bsmData.bsmArguments.get(i);
10921092
booleannotLastIdx =i !=bsmArgsLen -1;
10931093
sb.append(bsmArgAsString(bsmArgIdx,notLastIdx));
10941094
}
1095-
sb.append(RightBracket);
10961095
}
1096+
sb.append(RightBracket);
10971097
returnsb.toString();
10981098
}
10991099

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp