Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b147ce7
Preliminary support for record classes in `Procyon.CompilerTools`. F…
mstrobel Jun 10, 2021
be056da
Removed accidental import.
mstrobel Jun 12, 2021
afc4fae
Preliminary support for decompiling `module-info` classes.
mstrobel Jun 12, 2021
1c82d29
Added a transform to handle the newer try-with-resources patterns.
mstrobel Jun 12, 2021
a7d2909
Minor improvements to try-with-resources handling.
mstrobel Jun 13, 2021
b637869
Addendum to last commit.
mstrobel Jun 13, 2021
4dc7360
Improvements to record class handling, specifically with alternate co…
mstrobel Jun 13, 2021
6e8eb4a
Merge branch 'new-try-with-resources' into indy-string-concat
mstrobel Jun 13, 2021
6ad35c1
Lots of bug fixes, support for indy-based string concatenation, bette…
mstrobel Jun 16, 2021
94d8c72
Lots of bug fixes, support for indy-based string concatenation, bette…
mstrobel Jun 16, 2021
55d612b
Merge remote-tracking branch 'origin/post-java8-features' into post-j…
mstrobel Jun 18, 2021
11438fa
Fixed naming inconsistencies, fixed full name formatting of anonymous…
mstrobel Jun 18, 2021
ca1b948
Slightly smarter logic for hiding synthetic members that are only ref…
mstrobel Jun 18, 2021
0ae5095
Decent support for switch expressions, but more comprehensive support…
mstrobel Jun 19, 2021
1d9fcd6
Added preliminary support for text blocks and simple `instanceof` pat…
mstrobel Jun 19, 2021
10f6b9f
Improvements to Expressions library.
mstrobel Jul 4, 2021
512f1fd
Improved support for union types in catch clauses.
mstrobel Jul 4, 2021
fb53ab7
Added test run configurations.
mstrobel Jul 4, 2021
1d89d1e
Create CNAME
mstrobel Jul 4, 2021
47d0776
Delete CNAME
mstrobel Jul 4, 2021
730add1
Create CNAME
mstrobel Jul 4, 2021
0447413
Update CNAME
mstrobel Jul 4, 2021
3337098
Merge remote-tracking branch 'origin/develop' into post-java8-features
mstrobel Jul 4, 2021
739024c
Merge branch 'develop' into post-java8-features
mstrobel Jul 4, 2021
c45ec50
Fixed some issues with type inference and lambda decompilation. Reso…
mstrobel Jul 4, 2021
10b32a4
Fixed null result of `UnionType.getName()`.
mstrobel Jul 6, 2021
62e7d37
Attempt at removing dependency on `Unsafe::defineClass` in JDK9+.
mstrobel Jan 27, 2022
b825f06
Refactoring: changed `lookup` to `packageAccess` in `TypeBuilder`; re…
mstrobel Jan 31, 2022
e004e96
Added preliminary support for sealed types (JDK 17).
mstrobel Feb 4, 2022
2d8798b
Merge branch 'develop' into post-java8-features
mstrobel Feb 8, 2022
27b2dfb
Merge branch 'develop' into remove-unsafe-dependency
mstrobel Feb 9, 2022
511066c
More work on JDK9+ compatibility. Fixed a ton of raw type uses.
mstrobel-strike Feb 9, 2022
fbe972f
Merge pull request #45 from mstrobel-strike/remove-unsafe-dependency
mstrobel Feb 9, 2022
d52716d
Merge branch 'remove-unsafe-dependency' into v0.6-staging
mstrobel Feb 9, 2022
8586048
Merge branch 'post-java8-features' into v0.6-staging
mstrobel Feb 9, 2022
bea9e8c
Fixed enum value declaration decompilation in newer JDKs. Ignore cer…
mstrobel Feb 9, 2022
22aa03c
Merge branch 'post-java8-features' into v0.6-staging
mstrobel Feb 9, 2022
bed1b00
Merge branch 'develop' into post-java8-features
mstrobel Feb 16, 2022
18ae3f4
Merge branch 'remove-unsafe-dependency' into post-java8-features
mstrobel Feb 16, 2022
4d691bd
Added support for `ldc` instructions with `MethodHandle` operands.
mstrobel Feb 17, 2022
81fe8f1
Merge branch 'post-java8-features' into v0.6-staging
mstrobel Feb 17, 2022
9fabc62
Fixed some issues decompiling record classes with generic parameters.
mstrobel Feb 19, 2022
b8edf6c
Merge branch 'post-java8-features' into v0.6-staging
mstrobel Feb 19, 2022
6aadcb1
Restored commented-out method reference (lambda alternative) support.
mstrobel Feb 19, 2022
98ab048
Added some basic inlining of switch expressions when possible (e.g., …
mstrobel Feb 19, 2022
3ea38a8
Merge branch 'post-java8-features' into v0.6-staging
mstrobel Feb 19, 2022
ef3f8fd
Fixed issues with break target relocation and try-with-resources w/r/…
mstrobel Feb 21, 2022
c7ff5f8
Fixed issues with break target relocation and try-with-resources w/r/…
mstrobel Feb 21, 2022
02b3b38
Merge branch 'post-java8-features' into v0.6-staging
mstrobel Feb 21, 2022
d892d9f
Fixed compilation issue.
mstrobel Feb 21, 2022
7c3d8de
Merge branch 'post-java8-features' into v0.6-staging
mstrobel Feb 21, 2022
d6444f9
Updated version to v0.6.0.
mstrobel Feb 21, 2022
05ff703
Merge branch 'release/v0.6.0'
mstrobel Feb 21, 2022
88a95fa
Merge tag 'v0.6.0' into develop
mstrobel Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .run/Procyon.CompilerTools Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Procyon.CompilerTools Tests" type="JUnit" factoryName="JUnit">
<module name="Procyon.Procyon.CompilerTools.test" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
12 changes: 12 additions & 0 deletions .run/Procyon.Expressions Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Procyon.Expressions Tests" type="JUnit" factoryName="JUnit">
<module name="Procyon.Procyon.Expressions.test" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.strobel.core.ExceptionUtilities;
import com.strobel.core.VerifyArgument;
import com.strobel.decompiler.PlainTextOutput;
import com.strobel.functions.Block;
import com.strobel.functions.Consumer;
import com.strobel.functions.Function;

import java.io.File;
Expand Down Expand Up @@ -94,7 +94,7 @@ public final Iterable<ControlFlowNode> apply(final ControlFlowNode input) {
return input.getSuccessors();
}
},
new Block<ControlFlowNode>() {
new Consumer<ControlFlowNode>() {
@Override
public final void accept(final ControlFlowNode b) {
if (b == entryPoint) {
Expand Down Expand Up @@ -150,7 +150,7 @@ public final Iterable<ControlFlowNode> apply(final ControlFlowNode input) {
return input.getDominatorTreeChildren();
}
},
new Block<ControlFlowNode>() {
new Consumer<ControlFlowNode>() {
@Override
public void accept(final ControlFlowNode n) {
final Set<ControlFlowNode> dominanceFrontier = n.getDominanceFrontier();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.strobel.core.VerifyArgument;
import com.strobel.decompiler.DecompilerHelpers;
import com.strobel.decompiler.PlainTextOutput;
import com.strobel.functions.Block;
import com.strobel.functions.Consumer;
import com.strobel.functions.Function;
import com.strobel.util.ContractUtils;

Expand Down Expand Up @@ -240,7 +240,7 @@ public final Iterator<Instruction> iterator() {

public final void traversePreOrder(
final Function<ControlFlowNode, Iterable<ControlFlowNode>> children,
final Block<ControlFlowNode> visitAction) {
final Consumer<ControlFlowNode> visitAction) {

if (_visited) {
return;
Expand All @@ -256,7 +256,7 @@ public final void traversePreOrder(

public final void traversePostOrder(
final Function<ControlFlowNode, Iterable<ControlFlowNode>> children,
final Block<ControlFlowNode> visitAction) {
final Consumer<ControlFlowNode> visitAction) {

if (_visited) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,16 @@ public static ConstantPool read(final Buffer b) {
case MethodType:
new MethodTypeEntry(pool, b.readUnsignedShort());
break;
case DynamicConstant:
case InvokeDynamicInfo:
new InvokeDynamicInfoEntry(pool, b.readUnsignedShort(), b.readUnsignedShort());
break;
case Module:
new ModuleEntry(pool, b.readUnsignedShort());
break;
case Package:
new PackageEntry(pool, b.readUnsignedShort());
break;
}
}

Expand Down Expand Up @@ -520,7 +527,10 @@ public static enum Tag {
NameAndTypeDescriptor(12),
MethodHandle(15),
MethodType(16),
InvokeDynamicInfo(18);
DynamicConstant(17),
InvokeDynamicInfo(18),
Module(19),
Package(20);

public final int value;

Expand All @@ -529,16 +539,20 @@ public static enum Tag {
}

public static Tag fromValue(final int value) {
VerifyArgument.inRange(Tag.Utf8StringConstant.value, Tag.InvokeDynamicInfo.value, value, "value");
VerifyArgument.inRange(minTag.value, maxTag.value, value, "value");
return lookup[value];
}

private final static Tag minTag;
private final static Tag maxTag;
private final static Tag[] lookup;

static {
final Tag[] values = Tag.values();

lookup = new Tag[Tag.InvokeDynamicInfo.value + 1];
minTag = values[0];
maxTag = values[values.length - 1];
lookup = new Tag[maxTag.value + 1];

for (final Tag tag : values) {
lookup[tag.value] = tag;
Expand Down Expand Up @@ -566,6 +580,8 @@ public interface Visitor {
void visitMethodType(MethodTypeEntry info);
void visitStringConstant(StringConstantEntry info);
void visitUtf8StringConstant(Utf8StringConstantEntry info);
void visitModule(ModuleEntry info);
void visitPackage(PackageEntry info);
void visitEnd();

// <editor-fold defaultstate="collapsed" desc="Empty Visitor (No-Op)">
Expand Down Expand Up @@ -631,6 +647,14 @@ public void visitStringConstant(final StringConstantEntry info) {
public void visitUtf8StringConstant(final Utf8StringConstantEntry info) {
}

@Override
public void visitModule(final ModuleEntry info) {
}

@Override
public void visitPackage(final PackageEntry info) {
}

@Override
public void visitEnd() {
}
Expand Down Expand Up @@ -745,6 +769,18 @@ public void visitUtf8StringConstant(final Utf8StringConstantEntry info) {
codeStream.writeUtf8(info.value);
}

@Override
public void visitModule(final ModuleEntry info) {
codeStream.writeByte(info.getTag().value);
codeStream.writeShort(info.nameIndex);
}

@Override
public void visitPackage(final PackageEntry info) {
codeStream.writeByte(info.getTag().value);
codeStream.writeShort(info.nameIndex);
}

@Override
public void visitEnd() {
}
Expand Down Expand Up @@ -1073,6 +1109,96 @@ public String toString() {
}
}

public static class ModuleEntry extends ConstantEntry {

public final int nameIndex;

public ModuleEntry(final ConstantPool owner, final int nameIndex) {
super(owner);

this.nameIndex = nameIndex;
owner._newKey.set(getTag(), nameIndex);
owner._entryMap.put(owner._newKey.clone(), this);
owner._newKey.clear();
}

@Override
void fixupKey(final Key key) {
key.set(Tag.Module, nameIndex);
}

public Tag getTag() {
return Tag.Module;
}

public int byteLength() {
return 3;
}

public String getName() {
return ((Utf8StringConstantEntry) owner.get(nameIndex, Tag.Utf8StringConstant)).value;
}

public void accept(final Visitor visitor) {
visitor.visitModule(this);
}

@Override
public String toString() {
return "ModuleEntry[nameIndex: " + nameIndex + "]";
}

@Override
public Object getConstantValue() {
return getName();
}
}

public static class PackageEntry extends ConstantEntry {

public final int nameIndex;

public PackageEntry(final ConstantPool owner, final int nameIndex) {
super(owner);

this.nameIndex = nameIndex;
owner._newKey.set(getTag(), nameIndex);
owner._entryMap.put(owner._newKey.clone(), this);
owner._newKey.clear();
}

@Override
void fixupKey(final Key key) {
key.set(Tag.Package, nameIndex);
}

public Tag getTag() {
return Tag.Package;
}

public int byteLength() {
return 3;
}

public String getName() {
return ((Utf8StringConstantEntry) owner.get(nameIndex, Tag.Utf8StringConstant)).value;
}

public void accept(final Visitor visitor) {
visitor.visitPackage(this);
}

@Override
public String toString() {
return "PackageEntry[nameIndex: " + nameIndex + "]";
}

@Override
public Object getConstantValue() {
return getName();
}
}

public static final class DoubleConstantEntry extends ConstantEntry {
public final double value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.strobel.assembler.ir;

import com.strobel.assembler.metadata.MethodHandle;
import com.strobel.assembler.metadata.TypeReference;
import com.strobel.core.Comparer;
import com.strobel.core.VerifyArgument;
Expand Down Expand Up @@ -96,6 +97,10 @@ public static FrameValue makeReference(final TypeReference type) {
return new FrameValue(FrameValueType.Reference, VerifyArgument.notNull(type, "type"));
}

public static FrameValue makeMethodHandle(final MethodHandle handle) {
return new FrameValue(FrameValueType.Reference, VerifyArgument.notNull(handle, "handle"));
}

public static FrameValue makeAddress(final Instruction target) {
return new FrameValue(FrameValueType.Address, VerifyArgument.notNull(target, "target"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@

package com.strobel.assembler.ir;

import com.strobel.assembler.metadata.DynamicCallSite;
import com.strobel.assembler.metadata.FieldReference;
import com.strobel.assembler.metadata.Label;
import com.strobel.assembler.metadata.MethodReference;
import com.strobel.assembler.metadata.SwitchInfo;
import com.strobel.assembler.metadata.TypeReference;
import com.strobel.assembler.metadata.VariableReference;
import com.strobel.assembler.metadata.*;
import com.strobel.core.ArrayUtilities;
import com.strobel.core.VerifyArgument;
import com.strobel.decompiler.DecompilerHelpers;
Expand Down Expand Up @@ -530,6 +524,9 @@ public void accept(final InstructionVisitor visitor) {
else if (_operand instanceof TypeReference) {
visitor.visitConstant(_opCode, (TypeReference) _operand);
}
else if (_operand instanceof MethodHandle) {
visitor.visitConstant(_opCode, (MethodHandle) _operand);
}
else {
final Number number = (Number) _operand;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public interface InstructionVisitor {
void visit(final OpCode opCode);

void visitConstant(final OpCode opCode, final TypeReference value);
void visitConstant(final OpCode opCode, final MethodHandle value);
void visitConstant(final OpCode opCode, final int value);
void visitConstant(final OpCode opCode, final long value);
void visitConstant(final OpCode opCode, final float value);
Expand Down Expand Up @@ -63,6 +64,10 @@ public void visit(final OpCode opCode) {
public void visitConstant(final OpCode opCode, final TypeReference value) {
}

@Override
public void visitConstant(final OpCode opCode, final MethodHandle value) {
}

@Override
public void visitConstant(final OpCode opCode, final int value) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import java.util.List;

import static com.strobel.core.CollectionUtilities.lastOrDefault;

/**
* @author Mike Strobel
*/
Expand Down Expand Up @@ -265,14 +267,13 @@ protected SourceAttribute readAttributeCore(final String name, final Buffer buff
if (methodParameters != arguments.length + 3) {
final MethodDefinition resolved = bootstrapMethod.resolve();

final int varArgsAdjustment;

if(resolved == null || !resolved.isVarArgs()) {
varArgsAdjustment = 0;
}
else {
varArgsAdjustment = 1;
}
ParameterDefinition lastParameter;

final boolean varArgs = resolved != null ? resolved.isVarArgs()
: ((lastParameter = lastOrDefault(parameters)) != null &&
lastParameter.getParameterType().isArray());

final int varArgsAdjustment = varArgs ? 1 : 0;

final int varArgsAdjustedMethodParameters = methodParameters - varArgsAdjustment;

Expand Down
Loading