Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
aa2b95f2
Commit
aa2b95f2
authored
9 years ago
by
Egor.Ushakov
Browse files
Options
Download
Email Patches
Plain Diff
IDEA-149093 Decompiled code: invocation of static method on class with $ in name - fix prototype
parent
89151b22
Branches unavailable
Tags unavailable
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/DecompilerContext.java
+10
-0
...org/jetbrains/java/decompiler/main/DecompilerContext.java
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java
+1
-4
...ains/java/decompiler/main/collectors/ImportCollector.java
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/decompiler/BaseDecompiler.java
+7
-1
...rains/java/decompiler/main/decompiler/BaseDecompiler.java
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/extern/IClassNameHelper.java
+29
-0
...tbrains/java/decompiler/main/extern/IClassNameHelper.java
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
+9
-0
...ins/java/decompiler/modules/decompiler/ExprProcessor.java
plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt
+18
-0
...lugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt
with
74 additions
and
5 deletions
+74
-5
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/DecompilerContext.java
+
10
-
0
View file @
aa2b95f2
...
...
@@ -19,6 +19,7 @@ import org.jetbrains.java.decompiler.main.collectors.BytecodeSourceMapper;
import
org.jetbrains.java.decompiler.main.collectors.CounterContainer
;
import
org.jetbrains.java.decompiler.main.collectors.ImportCollector
;
import
org.jetbrains.java.decompiler.main.collectors.VarNamesCollector
;
import
org.jetbrains.java.decompiler.main.extern.IClassNameHelper
;
import
org.jetbrains.java.decompiler.main.extern.IFernflowerLogger
;
import
org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences
;
import
org.jetbrains.java.decompiler.modules.renamer.PoolInterceptor
;
...
...
@@ -46,6 +47,7 @@ public class DecompilerContext {
private
PoolInterceptor
poolInterceptor
;
private
IFernflowerLogger
logger
;
private
BytecodeSourceMapper
bytecodeSourceMapper
;
private
IClassNameHelper
classNameProvider
;
private
DecompilerContext
(
Map
<
String
,
Object
>
properties
)
{
this
.
properties
=
properties
;
...
...
@@ -135,6 +137,14 @@ public class DecompilerContext {
getCurrentContext
().
bytecodeSourceMapper
=
bytecodeSourceMapper
;
}
public
static
IClassNameHelper
getClassNameProvider
()
{
return
getCurrentContext
().
classNameProvider
;
}
public
static
void
setClassNameProvider
(
IClassNameHelper
classNameProvider
)
{
getCurrentContext
().
classNameProvider
=
classNameProvider
;
}
public
static
IFernflowerLogger
getLogger
()
{
return
getCurrentContext
().
logger
;
}
...
...
This diff is collapsed.
Click to expand it.
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java
+
1
-
4
View file @
aa2b95f2
/*
* Copyright 2000-201
5
JetBrains s.r.o.
* Copyright 2000-201
6
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.
...
...
@@ -73,9 +73,6 @@ public class ImportCollector {
return
retname
;
}
}
else
{
fullname
=
fullname
.
replace
(
'$'
,
'.'
);
}
String
nshort
=
fullname
;
String
npackage
=
""
;
...
...
This diff is collapsed.
Click to expand it.
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/decompiler/BaseDecompiler.java
+
7
-
1
View file @
aa2b95f2
/*
* Copyright 2000-201
4
JetBrains s.r.o.
* Copyright 2000-201
6
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.
...
...
@@ -15,8 +15,10 @@
*/
package
org.jetbrains.java.decompiler.main.decompiler
;
import
org.jetbrains.java.decompiler.main.DecompilerContext
;
import
org.jetbrains.java.decompiler.main.Fernflower
;
import
org.jetbrains.java.decompiler.main.extern.IBytecodeProvider
;
import
org.jetbrains.java.decompiler.main.extern.IClassNameHelper
;
import
org.jetbrains.java.decompiler.main.extern.IFernflowerLogger
;
import
org.jetbrains.java.decompiler.main.extern.IResultSaver
;
...
...
@@ -36,6 +38,10 @@ public class BaseDecompiler {
fernflower
.
getStructContext
().
addSpace
(
file
,
isOwn
);
}
public
void
setClassNameProvider
(
IClassNameHelper
provider
)
{
DecompilerContext
.
setClassNameProvider
(
provider
);
}
public
void
decompileContext
()
{
try
{
fernflower
.
decompileContext
();
...
...
This diff is collapsed.
Click to expand it.
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/extern/IClassNameHelper.java
0 → 100644
+
29
-
0
View file @
aa2b95f2
/*
* Copyright 2000-2016 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.
*/
package
org.jetbrains.java.decompiler.main.extern
;
/**
* Helper class to provide short name of ambiguous jvm class names like org.my/A$B
*/
public
interface
IClassNameHelper
{
/**
* Check class fqn like org.my/A$B
* and return org.my.A.B if it is an inner class
* or org.my.A$B if it is a real class name with $ inside
* or null if unknown
*/
String
getClassName
(
String
fqName
);
}
This diff is collapsed.
Click to expand it.
plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
+
9
-
0
View file @
aa2b95f2
...
...
@@ -22,6 +22,7 @@ import org.jetbrains.java.decompiler.code.cfg.BasicBlock;
import
org.jetbrains.java.decompiler.main.DecompilerContext
;
import
org.jetbrains.java.decompiler.main.TextBuffer
;
import
org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer
;
import
org.jetbrains.java.decompiler.main.extern.IClassNameHelper
;
import
org.jetbrains.java.decompiler.modules.decompiler.exps.*
;
import
org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectGraph
;
import
org.jetbrains.java.decompiler.modules.decompiler.sforms.DirectNode
;
...
...
@@ -776,6 +777,14 @@ public class ExprProcessor implements CodeConstants {
}
public
static
String
buildJavaClassName
(
String
name
)
{
IClassNameHelper
classNameProvider
=
DecompilerContext
.
getClassNameProvider
();
if
(
classNameProvider
!=
null
)
{
String
res
=
classNameProvider
.
getClassName
(
name
);
if
(
res
!=
null
)
{
return
res
;
}
}
String
res
=
name
.
replace
(
'/'
,
'.'
);
if
(
res
.
contains
(
"$"
))
{
// attempt to invoke foreign member
...
...
This diff is collapsed.
Click to expand it.
plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt
+
18
-
0
View file @
aa2b95f2
...
...
@@ -29,6 +29,7 @@ import com.intellij.openapi.progress.ProcessCanceledException
import
com.intellij.openapi.progress.ProgressIndicator
import
com.intellij.openapi.progress.ProgressManager
import
com.intellij.openapi.project.DefaultProjectFactory
import
com.intellij.openapi.project.ProjectManager
import
com.intellij.openapi.ui.DialogWrapper
import
com.intellij.openapi.util.io.FileUtil
import
com.intellij.openapi.util.registry.Registry
...
...
@@ -36,9 +37,11 @@ import com.intellij.openapi.util.text.StringUtil
import
com.intellij.openapi.vfs.VirtualFile
import
com.intellij.openapi.vfs.newvfs.RefreshQueue
import
com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent
import
com.intellij.psi.PsiManager
import
com.intellij.psi.codeStyle.CodeStyleSettingsManager
import
com.intellij.psi.compiled.ClassFileDecompilers
import
com.intellij.psi.impl.compiled.ClsFileImpl
import
com.intellij.psi.util.ClassUtil
import
com.intellij.util.containers.ContainerUtil
import
org.jetbrains.annotations.TestOnly
import
org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler
...
...
@@ -157,6 +160,21 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
val
saver
=
MyResultSaver
()
val
decompiler
=
BaseDecompiler
(
provider
,
saver
,
options
,
myLogger
.
value
)
files
.
keys
.
forEach
{
path
->
decompiler
.
addSpace
(
File
(
path
),
true
)
}
ApplicationManager
.
getApplication
().
runReadAction
{
val
openProjects
=
ProjectManager
.
getInstance
().
openProjects
val
project
=
openProjects
.
filter
{
p
->
PsiManager
.
getInstance
(
p
).
findFile
(
file
)
!=
null
}.
firstOrNull
()
project
?.
let
{
decompiler
.
setClassNameProvider
{
fqn
->
ApplicationManager
.
getApplication
().
runReadAction
<
String
>
{
ClassUtil
.
findPsiClass
(
PsiManager
.
getInstance
(
project
),
fqn
.
replace
(
"/"
,
"."
),
null
,
true
)
?.
qualifiedName
}
}
}
}
decompiler
.
decompileContext
()
val
mapping
=
saver
.
myMapping
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help