• Post Reply Bookmark Topic Watch Topic
  • New Topic

wierd problems..  RSS feed

 
Ranganath Junpal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I recently decompiled some source code from .jar file. I am having some weird problems. Its having $ fixes in between the variables and class names. And i am getting errors saying the name is already in use for code like this

// here It says that "clazzName" is already used pointing to theconstructer.
class clazzName
{
public clazzName(){}
}

Even i get error in the class as these
private class CodeReport$ReportItem
//> it says only public,abstract, final is permitted
{
}

Other errors are like
static class JRestrictedTextField$RestrictedTextDocument extends PlainDocument
{
}
-> the above class declaration again gives the same error as public, abstract,final is permitted..

and i have lots of .java files similiar to other like splashscreen.java,splashscreen$1.java,splashscreen$2.java etc.. the code within is relatively same?
Please let me know how to sort it out. Is is because that code is obfuscated. if so how to de-Obfuscate it?

Thank you
Regards
[ February 08, 2007: Message edited by: Ranganath Junpal ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you decompiled some class files (with which decompiler?) and now you are trying to re-compile them?

Are you sure that the decompiler produces valid Java source code? Some decompilers produce a file with Java-like source code, but it isn't real Java source code that you can just recompile like that.

About the "$" in the names: The name after the "$" is the name of a nested class. If it is just a number, then it was an anonymous inner class in the original source code. The code does not look obfuscated - the "$" are normal.

Try compiling something like the following piece of code. Notice that you will get TWO class files: Demo.class and Demo$1.class. The second one is the class file for the anonymous inner class. This is normal - that's just the way the Java compiler handles inner classes.

[ February 09, 2007: Message edited by: Jesper Young ]
 
Ranganath Junpal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I am sure its a java code. because i have other modules which is fine with out any problems.
It is java code.. see this is one of those classes which i have decompiled.

import javax.swing.text.*;

static class JIntegerField$NumericDocument extends PlainDocument
{

public void insertString(int i, String s, AttributeSet attributeset)
throws BadLocationException
{
if(s == null)
return;
char ac[] = s.toCharArray();
int j = 0;
for(int k = 0; k < ac.length; k++)
if(!Character.isDigit(ac[k]))
{
ac[k] = 'E';
j++;
}

char ac1[] = new char[ac.length - j];
int l = j;
for(int i1 = 0; i1 < ac.length; i1++)
if(ac[i1] != 'E')
ac1[i1 - (j - l)] = ac[i1];
else
l--;

String s1 = new String(ac1);
if(s1.length() + getLength() > 9)
s1 = s1.substring(0, 9 - getLength());
super.insertString(i, s1, attributeset);
}

JIntegerField$NumericDocument()
{
}
}

Thank you
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I am sure its a java code. because i have other modules which is fine with out any problems.


You're missing Jespers point. Obviously, the decompiler tries to generate valid Java source code, but it doesn't always succeed, in which case you'll have to fix the source code. So just because some other class gets decompiled correctly, doesn't mean that this particular class gets decompiled correctly, too.

By the way, what code is this that you're decompiling? Are you allowed to do so?
 
Ranganath Junpal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes very much..its a code of some legacy system of our companie internal application. unfortunately the code is completely messed up. So we are trying to re construct using its .jar file. BTW do let me know whic decompiler is good to use. I think i decompiled this using Mocha..
[ February 09, 2007: Message edited by: Ranganath Junpal ]
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
static class JIntegerField$NumericDocument extends PlainDocument { ...

Did you understand my note about the "$"? So the original source code would have looked something like this:

I don't know why your Java decompiler doesn't automatically decompiles it like this. Maybe your decompiler doesn't understand nested classes properly.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!