decompiler: fixed inner class constructor signature decompilation
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000-2014 JetBrains s.r.o.
|
* Copyright 2000-2015 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -639,7 +639,16 @@ public class ClassWriter {
|
|||||||
descriptor = GenericMain.parseMethodSignature(attr.getSignature());
|
descriptor = GenericMain.parseMethodSignature(attr.getSignature());
|
||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
int actualParams = md.params.length;
|
int actualParams = md.params.length;
|
||||||
if (isEnum && init) actualParams -= 2;
|
List<VarVersionPair> sigFields = methodWrapper.signatureFields;
|
||||||
|
if (sigFields != null) {
|
||||||
|
actualParams = 0;
|
||||||
|
for (VarVersionPair field : methodWrapper.signatureFields) {
|
||||||
|
if (field == null) {
|
||||||
|
actualParams++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isEnum && init) actualParams -= 2;
|
||||||
if (actualParams != descriptor.params.size()) {
|
if (actualParams != descriptor.params.size()) {
|
||||||
String message = "Inconsistent generic signature in method " + mt.getName() + " " + mt.getDescriptor();
|
String message = "Inconsistent generic signature in method " + mt.getName() + " " + mt.getDescriptor();
|
||||||
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
|
DecompilerContext.getLogger().writeMessage(message, IFernflowerLogger.Severity.WARN);
|
||||||
@@ -685,10 +694,11 @@ public class ClassWriter {
|
|||||||
|
|
||||||
boolean firstParameter = true;
|
boolean firstParameter = true;
|
||||||
int index = isEnum && init ? 3 : thisVar ? 1 : 0;
|
int index = isEnum && init ? 3 : thisVar ? 1 : 0;
|
||||||
int start = isEnum && init && descriptor == null ? 2 : 0;
|
boolean hasDescriptor = descriptor != null;
|
||||||
int params = descriptor == null ? md.params.length : descriptor.params.size();
|
int start = isEnum && init && !hasDescriptor ? 2 : 0;
|
||||||
|
int params = hasDescriptor ? descriptor.params.size() : md.params.length;
|
||||||
for (int i = start; i < params; i++) {
|
for (int i = start; i < params; i++) {
|
||||||
if (signFields == null || signFields.get(i) == null) {
|
if (hasDescriptor || (signFields == null || signFields.get(i) == null)) {
|
||||||
if (!firstParameter) {
|
if (!firstParameter) {
|
||||||
buffer.append(", ");
|
buffer.append(", ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,4 +58,5 @@ public class SingleClassesTest extends SingleClassesTestBase {
|
|||||||
@Test public void testAnonymousClass() { doTest("pkg/TestAnonymousClass"); }
|
@Test public void testAnonymousClass() { doTest("pkg/TestAnonymousClass"); }
|
||||||
@Test public void testThrowException() { doTest("pkg/TestThrowException"); }
|
@Test public void testThrowException() { doTest("pkg/TestThrowException"); }
|
||||||
@Test public void testInnerLocal() { doTest("pkg/TestInnerLocal"); }
|
@Test public void testInnerLocal() { doTest("pkg/TestInnerLocal"); }
|
||||||
|
@Test public void testInnerSignature() { doTest("pkg/TestInnerSignature"); }
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
testData/classes/pkg/TestInnerSignature$Inner.class
Normal file
BIN
testData/classes/pkg/TestInnerSignature$Inner.class
Normal file
Binary file not shown.
BIN
testData/classes/pkg/TestInnerSignature$InnerStatic.class
Normal file
BIN
testData/classes/pkg/TestInnerSignature$InnerStatic.class
Normal file
Binary file not shown.
BIN
testData/classes/pkg/TestInnerSignature.class
Normal file
BIN
testData/classes/pkg/TestInnerSignature.class
Normal file
Binary file not shown.
70
testData/results/TestInnerSignature.dec
Normal file
70
testData/results/TestInnerSignature.dec
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
public class TestInnerSignature<A, B, C> {
|
||||||
|
A a;
|
||||||
|
B b;
|
||||||
|
C c;
|
||||||
|
|
||||||
|
public TestInnerSignature(A var1, B var2, C var3) {
|
||||||
|
this.a = var1;// 23
|
||||||
|
this.b = var2;// 24
|
||||||
|
this.c = var3;// 25
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InnerStatic<A, B, C> {
|
||||||
|
A a;
|
||||||
|
B b;
|
||||||
|
C c;
|
||||||
|
|
||||||
|
public InnerStatic(A var1, B var2, C var3) {
|
||||||
|
this.a = var1;// 46
|
||||||
|
this.b = var2;// 47
|
||||||
|
this.c = var3;// 48
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Inner {
|
||||||
|
A a;
|
||||||
|
B b;
|
||||||
|
C c;
|
||||||
|
|
||||||
|
public Inner(A var1, B var2, C var3) {
|
||||||
|
this.a = var2;// 34
|
||||||
|
this.b = var3;// 35
|
||||||
|
this.c = var4;// 36
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class 'TestInnerSignature' {
|
||||||
|
method '<init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V' {
|
||||||
|
6 6
|
||||||
|
b 7
|
||||||
|
10 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class 'TestInnerSignature$InnerStatic' {
|
||||||
|
method '<init> (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V' {
|
||||||
|
6 17
|
||||||
|
b 18
|
||||||
|
10 19
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class 'TestInnerSignature$Inner' {
|
||||||
|
method '<init> (LTestInnerSignature;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V' {
|
||||||
|
b 29
|
||||||
|
10 30
|
||||||
|
16 31
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Lines mapping:
|
||||||
|
23 <-> 7
|
||||||
|
24 <-> 8
|
||||||
|
25 <-> 9
|
||||||
|
34 <-> 30
|
||||||
|
35 <-> 31
|
||||||
|
36 <-> 32
|
||||||
|
46 <-> 18
|
||||||
|
47 <-> 19
|
||||||
|
48 <-> 20
|
||||||
51
testData/src/pkg/TestInnerSignature.java
Normal file
51
testData/src/pkg/TestInnerSignature.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2000-2014 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TestInnerSignature<A,B,C> {
|
||||||
|
A a;
|
||||||
|
B b;
|
||||||
|
C c;
|
||||||
|
|
||||||
|
public TestInnerSignature(A a,B b,C c) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.c = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Inner {
|
||||||
|
A a;
|
||||||
|
B b;
|
||||||
|
C c;
|
||||||
|
|
||||||
|
public Inner(A a, B b, C c) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.c = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InnerStatic<A,B,C> {
|
||||||
|
A a;
|
||||||
|
B b;
|
||||||
|
C c;
|
||||||
|
|
||||||
|
public InnerStatic(A a, B b, C c) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
this.c = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user