Skip to content

Commit e2e4ce4

Browse files
author
emmanue1
committed
Initial commit
1 parent 09988cb commit e2e4ce4

File tree

446 files changed

+50175
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

446 files changed

+50175
-8
lines changed

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Declare OSX files that will always have LF line endings on checkout.
5+
Info.plist text eol=lf
6+
7+
# Declare script files that will always have LF line endings on checkout.
8+
*.sh text eol=lf
9+
10+
# Declare script files that will always have CR/LF line endings on checkout.
11+
*.bat text eol=crlf
12+
13+
# Denote all files that are truly binary and should not be modified.
14+
*.png binary
15+
*.jpg binary
16+
*.gif binary
17+
*.icns binary

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Java
2+
*.class
3+
4+
# JD
5+
debug*
6+
7+
# Idea
8+
.idea/
9+
out/
10+
*.ipr
11+
*.iml
12+
*.iws
13+
14+
# Eclipse
15+
.settings/
16+
classes/
17+
.classpath
18+
.project
19+
20+
# Mac
21+
.DS_Store
22+
23+
# Windows
24+
Thumbs.db
25+
26+
# Maven
27+
log/
28+
target/
29+
30+
# Gradle
31+
.gradle/
32+
build/
33+
!gradle/wrapper/*
34+
35+
# WinMerge
36+
*.bak

LICENSE

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
GNU GENERAL PUBLIC LICENSE
1+
GNU GENERAL PUBLIC LICENSE
2+
23
Version 3, 29 June 2007
34

4-
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
56
Everyone is permitted to copy and distribute verbatim copies
67
of this license document, but changing it is not allowed.
78

@@ -631,8 +632,8 @@ to attach them to the start of each source file to most effectively
631632
state the exclusion of warranty; and each file should have at least
632633
the "copyright" line and a pointer to where the full notice is found.
633634

634-
<one line to give the program's name and a brief idea of what it does.>
635-
Copyright (C) <year> <name of author>
635+
JD-Core, a JAVA decompiler
636+
Copyright (C) 2008-2019 Emmanuel Dupuy
636637

637638
This program is free software: you can redistribute it and/or modify
638639
it under the terms of the GNU General Public License as published by
@@ -645,14 +646,14 @@ the "copyright" line and a pointer to where the full notice is found.
645646
GNU General Public License for more details.
646647

647648
You should have received a copy of the GNU General Public License
648-
along with this program. If not, see <https://www.gnu.org/licenses/>.
649+
along with this program. If not, see <http://www.gnu.org/licenses/>.
649650

650651
Also add information on how to contact you by electronic and paper mail.
651652

652653
If the program does terminal interaction, make it output a short
653654
notice like this when it starts in an interactive mode:
654655

655-
<program> Copyright (C) <year> <name of author>
656+
JD-Core Copyright (C) 2008-2019 Emmanuel Dupuy
656657
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657658
This is free software, and you are welcome to redistribute it
658659
under certain conditions; type `show c' for details.
@@ -664,11 +665,11 @@ might be different; for a GUI interface, you would use an "about box".
664665
You should also get your employer (if you work as a programmer) or school,
665666
if any, to sign a "copyright disclaimer" for the program, if necessary.
666667
For more information on this, and how to apply and follow the GNU GPL, see
667-
<https://www.gnu.org/licenses/>.
668+
<http://www.gnu.org/licenses/>.
668669

669670
The GNU General Public License does not permit incorporating your program
670671
into proprietary programs. If your program is a subroutine library, you
671672
may consider it more useful to permit linking proprietary applications with
672673
the library. If this is what you want to do, use the GNU Lesser General
673674
Public License instead of this License. But first, please read
674-
<https://www.gnu.org/licenses/why-not-lgpl.html>.
675+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

NOTICE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
JD-Core license - GPLv3

README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# JD-Core
2+
3+
JD-Core is a JAVA decompiler written in JAVA.
4+
5+
- Java Decompiler projects home page:
6+
[http://java-decompiler.github.io](http://java-decompiler.github.io)
7+
- JD-GUI source code:
8+
[https://github.com/java-decompiler/jd-core](https://github.com/java-decompiler/jd-core)
9+
- Maven repository:
10+
[https://raw.github.com/java-decompiler/mvn-repo/master](https://raw.github.com/java-decompiler/mvn-repo/master)
11+
12+
## Description
13+
JD-Core is a standalone JAVA library containing the JAVA decompiler of
14+
"Java Decompiler project". It support Java 1.1.8 to Java 10.0,
15+
including Lambda expressions, method references and default methods.
16+
JD-Core is the engine of JD-GUI.
17+
18+
## How to build JD-Core ?
19+
```
20+
> git clone https://github.com/java-decompiler/jd-core.git
21+
> cd jd-core
22+
> ./gradlew build
23+
```
24+
generate _"build/libs/jd-core-x.y.z.jar"_
25+
26+
## How to use JD-Core ?
27+
28+
1. Implement the
29+
_[jd.core.loader.Loader](https://github.com/java-decompiler/jd-core/blob/master/src/main/java/org/jd/core/loader/Loader.java)_
30+
interface,
31+
2. Implement the
32+
_[jd.core.printer.Printer](https://github.com/java-decompiler/jd-core/blob/master/src/main/java/org/jd/core/printer/Printer.java)_
33+
interface,
34+
3. And call the method _"decompile(loader, printer, internalTypeName);"_
35+
36+
## Example
37+
38+
1. Implement the _Loader_ interface:
39+
```java
40+
Loader loader = new Loader() {
41+
@Override
42+
public byte[] load(String internalName) throws LoaderException {
43+
InputStream is = this.getClass().getResourceAsStream("/" + internalName + ".class");
44+
45+
if (is == null) {
46+
return null;
47+
} else {
48+
try (InputStream in=is; ByteArrayOutputStream out=new ByteArrayOutputStream()) {
49+
byte[] buffer = new byte[1024];
50+
int read = in.read(buffer);
51+
52+
while (read > 0) {
53+
out.write(buffer, 0, read);
54+
read = in.read(buffer);
55+
}
56+
57+
return out.toByteArray();
58+
} catch (IOException e) {
59+
throw new LoaderException(e);
60+
}
61+
}
62+
}
63+
64+
@Override
65+
public boolean canLoad(String internalName) {
66+
return this.getClass().getResource("/" + internalName + ".class") != null;
67+
}
68+
};
69+
```
70+
71+
2. Implement the _Printer_ interface
72+
```java
73+
Printer printer = new Printer() {
74+
protected static final String TAB = " ";
75+
protected static final String NEWLINE = "\n";
76+
77+
protected int indentationCount = 0;
78+
protected StringBuilder sb = new StringBuilder();
79+
80+
@Override public String toString() { return sb.toString(); }
81+
82+
@Override public void start(int maxLineNumber, int majorVersion, int minorVersion) {}
83+
@Override public void end() {}
84+
85+
@Override public void printText(String text) { sb.append(text); }
86+
@Override public void printNumericConstant(String constant) { sb.append(constant); }
87+
@Override public void printStringConstant(String constant, String ownerInternalName) { sb.append(constant); }
88+
@Override public void printKeyword(String keyword) { sb.append(keyword); }
89+
@Override public void printDeclaration(int flags, String internalTypeName, String name, String descriptor) { sb.append(name); }
90+
@Override public void printReference(int flags, String internalTypeName, String name, String descriptor, String ownerInternalName) { sb.append(name); }
91+
92+
@Override public void indent() { this.indentationCount++; }
93+
@Override public void unindent() { if (this.indentationCount > 0) this.indentationCount--; }
94+
95+
@Override public void startLine(int lineNumber) { for (int i=0; i<indentationCount; i++) sb.append(TAB); }
96+
@Override public void endLine() { sb.append(NEWLINE); }
97+
@Override public void extraLine(int count) { while (count-- > 0) sb.append(NEWLINE); }
98+
99+
@Override public void startMarker(int type) {}
100+
@Override public void endMarker(int type) {}
101+
};
102+
```
103+
104+
3. And call the method _"decompile(loader, printer, internalTypeName);"_
105+
```java
106+
ClassFileToJavaSourceDecompiler decompiler = new
107+
ClassFileToJavaSourceDecompiler();
108+
109+
decompiler.decompile(loader, printer, "path/to/YourClass");
110+
111+
String source = printer.toString();
112+
```

build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'java'
2+
apply plugin: 'eclipse'
3+
apply plugin: 'idea'
4+
5+
dependencies {
6+
testCompile 'junit:junit:4.12'
7+
}
8+
9+
version='1.0.0'
10+
11+
tasks.withType(JavaCompile) {
12+
sourceCompatibility = targetCompatibility = '1.8'
13+
options.compilerArgs << '-Xlint:deprecation'
14+
options.compilerArgs << '-Xlint:unchecked'
15+
options.encoding = 'UTF-8'
16+
}
17+
18+
repositories {
19+
mavenCentral()
20+
}
21+
22+
jar {
23+
manifest {
24+
attributes 'JD-Core-Version': version
25+
}
26+
}
27+
28+
// 'cleanIdea' task extension //
29+
cleanIdea.doFirst {
30+
delete project.name + '.iws'
31+
delete 'out'
32+
followSymlinks = true
33+
}

gradle/wrapper/gradle-wrapper.jar

51 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Sat Mar 02 11:11:32 CET 2019
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip

0 commit comments

Comments
 (0)