Skip to content

Commit

Permalink
Fix for Eclipse 2024-03
Browse files Browse the repository at this point in the history
  • Loading branch information
jpstotz committed Mar 15, 2024
1 parent 5a9a574 commit f2b6022
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 46 deletions.
64 changes: 36 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,19 @@ Since version 3.3.0 ECD is signed by a self-signed 4096 bit RSA key:
* SHA-256 fingerprint: 8A 68 55 D3 91 B7 6F 95 DA D1 1E DF 1C 38 8D 38 F1 8A 0C A2 97 E5 12 85 DD 5B 05 9C C3 21 1B D4
* Certificate file: [ecd.cer](ecd.cer)

## Licenses

The main plugin and the _org.sf.feeling.decompiler.jd_ project are licensed under [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html), the other feature plugins are licensed under the [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html)

Code partially based on:
* JD-Eclipse: Copyright Emmanuel Dupuy, [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html)
* Java Source Attacher: Copyright Thai Ha, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)

Used libraries:
* Dr. Garbage Tools: Copyright (c) Dr. Garbage Ltd. & Co KG, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Apache commons: Copyright (c) Apache Software Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Fernflower: Copyright (c) JetBrains, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Minimal JSON: Copyright (c) 2013, 2014 EclipseSource, [MIT License](https://opensource.org/licenses/MIT)
* CFR: Copyright Leee Benfield, [MIT License](https://opensource.org/licenses/MIT)
* Procyon: Copyright Mike Strobel, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Netbeans CVSClient: Copyright (c) NetBeans Community, [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html) and [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Maven SCM: Copyright (c) Apache Software Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Nexus Indexer: [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Nexus Restlet1x Model: [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html)
* Plexus Utils: Copyright The Codehaus Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* JD-Core: Copyright Emmanuel Dupuy, [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html)
* Vineflower: [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
## Eclipse Photon to Eclipse 2021-03

## Contributors
Due to a signature bug in all Eclipse versions up to (including) Eclipse 2021-03, the signed releases of Enhanced Class Decompiler (ECD) 3.4.1 and newer can no longer be used. Please download the latest unsigned repository from the [ECD releases](https://github.com/ecd-plugin/ecd/releases) and install it manually in Eclipse.

* Chen Chao ([email protected]) - initial API and implementation
* Robert Zenz
* Pascal Bihler
* Nick Lombard
* Jan Peter Stotz
This affects the release version published on https://ecd-plugin.github.io/update/ and also the version installable via Eclipse Marketplace as it uses this update site.

## Changelog
* Version 3.4.1
* Moved FernFlower into own plugin/feature
* Quiltflower plugin and feature removed
* Vineflower plugin and feature added (replaces Quiltflower)
* Removed "Source" (source.attach) plugin and feature
* Updated build envoironment to use Java 17

* Version 3.4.0
* Updated Embedded Decompilers
Expand Down Expand Up @@ -146,3 +123,34 @@ Used libraries:
* Removed extra-header in code (Issue [upstream#2](https://github.com/cnfree/Eclipse-Class-Decompiler/issues/28))
* Display information about class being decompiled in editor title (Issue #3)
* Made plug-in work with Java9 BETA JDT core

## Licenses

The main plugin and the _org.sf.feeling.decompiler.jd_ project are licensed under [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html), the other feature plugins are licensed under the [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html)

Code partially based on:
* JD-Eclipse: Copyright Emmanuel Dupuy, [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html)
* Java Source Attacher: Copyright Thai Ha, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)

Used libraries:
* Dr. Garbage Tools: Copyright (c) Dr. Garbage Ltd. & Co KG, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Apache commons: Copyright (c) Apache Software Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Fernflower: Copyright (c) JetBrains, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Minimal JSON: Copyright (c) 2013, 2014 EclipseSource, [MIT License](https://opensource.org/licenses/MIT)
* CFR: Copyright Leee Benfield, [MIT License](https://opensource.org/licenses/MIT)
* Procyon: Copyright Mike Strobel, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Netbeans CVSClient: Copyright (c) NetBeans Community, [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html) and [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Maven SCM: Copyright (c) Apache Software Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Nexus Indexer: [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* Nexus Restlet1x Model: [Eclipse Public License v1.0](https://www.eclipse.org/legal/epl-v10.html)
* Plexus Utils: Copyright The Codehaus Foundation, [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
* JD-Core: Copyright Emmanuel Dupuy, [GPL 3](https://www.gnu.org/licenses/gpl-3.0-standalone.html)
* Vineflower: [Apache License V2.0](https://www.apache.org/licenses/LICENSE-2.0.html)

## Contributors

* Chen Chao ([email protected]) - initial API and implementation
* Robert Zenz
* Pascal Bihler
* Nick Lombard
* Jan Peter Stotz
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.jdt.internal.core.BufferManager;
import org.eclipse.jdt.internal.core.ClassFile;
import org.eclipse.jdt.internal.core.SourceMapper;
import org.sf.feeling.decompiler.util.EclipseCompatibilityHelper;
import org.sf.feeling.decompiler.util.SourceMapperUtil;

public class ClassFileSourceMap {
Expand Down Expand Up @@ -81,7 +82,7 @@ public static void updateSource(JavaDecompilerBufferManager bufferManager, Class
if (!type.isBinary()) {
return;
}
Object info = cf.getElementInfo();
Object info = EclipseCompatibilityHelper.javaElementGetElementInfo(cf);
IType enclosingType = type.getDeclaringType();
while (enclosingType != null) {
type = enclosingType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.text.edits.TextEdit;
import org.sf.feeling.decompiler.JavaDecompilerPlugin;
import org.sf.feeling.decompiler.util.DecompilerOutputUtil;
import org.sf.feeling.decompiler.util.EclipseCompatibilityHelper;
import org.sf.feeling.decompiler.util.SourceMapperUtil;

public abstract class DecompilerSourceMapper extends SourceMapper {
Expand All @@ -56,10 +57,7 @@ public char[] findSource(IType type) throws JavaModelException {
declType = parent;
parent = (BinaryType) declType.getDeclaringType();
}
IBinaryType info = null;

info = (IBinaryType) declType.getElementInfo();

IBinaryType info = EclipseCompatibilityHelper.binaryTypeGetElementInfo(declType);
if (info == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static String updateBuffer(IClassFile cf, String origSrc) throws JavaMode
public static void updateSourceRanges(IClassFile cf, String contents) throws JavaModelException {
if (cf instanceof ClassFile) {
ClassFile classFile = (ClassFile) cf;
Object info = classFile.getElementInfo();
Object info = EclipseCompatibilityHelper.javaElementGetElementInfo(classFile);
IBinaryType typeInfo = info instanceof IBinaryType ? (IBinaryType) info : null;
SourceMapper mapper = classFile.getSourceMapper();
IType type = (IType) ReflectionUtils.invokeMethod(classFile, "getOuterMostEnclosingType", //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.sf.feeling.decompiler.util;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.core.BinaryType;
import org.eclipse.jdt.internal.core.JavaElement;

public class EclipseCompatibilityHelper {

public static IBinaryType binaryTypeGetElementInfo(BinaryType binaryType) {
// In Eclipse 2024-03 the method return type of getElementInfo() has been
// changed from Object to IBinaryType. This can cause a NoSuchMethodError.
// depending on the used Eclipse version.
// Therefore we call his method using reflection to be safe.
try {
Method getElemInfoMethod = binaryType.getClass().getMethod("getElementInfo");
return (IBinaryType) getElemInfoMethod.invoke(binaryType);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}

public static Object javaElementGetElementInfo(JavaElement classFile) {
// In Eclipse 2024-03 the method return type of getElementInfo() has been
// changed from Object to IElementInfo. This can cause a NoSuchMethodError
// depending on the used Eclipse version.
// Therefore we call his method using reflection to be safe.
try {
Method getElemInfoMethod = classFile.getClass().getMethod("getElementInfo");
return getElemInfoMethod.invoke(classFile);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public static Method getDeclaredMethod(Class clazz, String methodName, Class[] p
}

public static Method getDeclaredMethod(Object object, String methodName, Class[] parameterTypes) {
if (object == null || methodName == null)
if (object == null || methodName == null) {
return null;
}

for (Class clazz = object.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
try {
return clazz.getDeclaredMethod(methodName, parameterTypes);
} catch (Exception e) {

}
}

Expand Down
11 changes: 1 addition & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tycho.version>2.7.5</tycho.version>
<maven.dependency.plugin.version>3.5.0</maven.dependency.plugin.version>
<maven.dependency.plugin.version>3.5.0</maven.dependency.plugin.version>
<signing.disabled>true</signing.disabled>
</properties>
<modules>
Expand All @@ -25,10 +25,6 @@
<module>org.sf.feeling.decompiler.fernflower.feature</module>
<module>org.sf.feeling.decompiler.vineflower</module>
<module>org.sf.feeling.decompiler.vineflower.feature</module>
<!--
<module>org.sf.feeling.decompiler.source.attach</module>
<module>org.sf.feeling.decompiler.source.feature</module>
-->
<module>update_site</module>
</modules>
<build>
Expand Down Expand Up @@ -119,11 +115,6 @@
<keypass>${signing.password}</keypass>
<verbose>true</verbose>
<certs>true</certs>
<arguments>
<argument>-digestalg</argument><argument>SHA-256</argument>
<argument>-sigalg</argument><argument>SHA256withRSA</argument>
<argument>-tsadigestalg</argument><argument>SHA-256</argument>
</arguments>
</configuration>
<executions>
<execution>
Expand Down

0 comments on commit f2b6022

Please sign in to comment.