Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AspectJ and obfuscator

Hi,

the problem in my case is, that I need obfuscation, cause without
obfuscation the project I am developing doesn't run. I am writing a small
J2ME program, which uses the bouncycastle crypto library. Some of the
algorithms I am using there, needs the class java.math.BigInteger. This
class is not supported by J2ME in the standard. As far as I understand and read in several
examples and in the mailinglist from bouncycastle, if I need classes like
the java.math.BigInteger, I need this obfuscation process, so that my
program runs correctly. In fact, for my purpose, I don't need the
obfuscation to safe the bytecode of my project from a breakdown. I only need
it, so that the project runs well. If one can tell me, how to get my
programs (or for example the example from:
http://developers.sun.com/techtopics/mobility/midp/articles/security3/) I
wouldn't use the obfuscator, cause things are getting more and more complex with such programs (I spend 4 days to write the Ant-file, that everything compile and run almost normal, but some things are changed now in the running process and things are some kind of strange now, so that I have to rewrite some parts of my software now ;( )... Things are getting more and more complex with this trillion of development-tools to use, only to write a simple tool... In the article, I mentioned above, it is written, that the obfuscation-process is cruial to
midlet development, because of 2 reasons:
(i) Even the lightweight Bouncy Castle package weighs in at around 350 KB --
clearly too large when the practical upper limit on MIDlet suites is about
50 KB. An obfuscator can remove unused classes and interfaces (especially
important when using a third-party library) and can condense the code used
in the MIDlet.
(ii) The Bouncy Castle APIs include reimplementations of J2SE classes like
java.math.BigInteger and java.security.SecureRandom. Applications aren't
allowed to define classes in the java.* namespace. MIDP devices, including
the J2ME Wireless Toolkit 2.0 emulators, will not run a MIDlet suite that
includes java.* classes. An obfuscator can rename the classes so they will
not be in the restricted namespace.

Bye,
Sebastian

[quote Ted Neward::on 2/6/2005 12:27 PM]
| BTW, just so you know, obfuscation can often confuse the hell out of the
JIT
| compiler (if there is one) and can slow down execution (even if there
isn't
| a JIT compiler), since it tends to do some strange things with bytecode
in
| order to make it less readable (and, by extension, less easily
executed).
| I've heard, anecdotally, of slowdowns of up to 33% due to obfuscation.
|
| As a general rule, if you put code on my machine, I can reverse it
| regardless of what kinds of protection you put on it. (If all else
fails, I
| can slap a debugger on the running process and watch it that way.) You
might
| want to seriously reconsider the obfuscation step entirely.
|
| Ted Neward
| Author, Instructor, Consultant
| Java, .NET, Web services
| http://www.neward.net/ted
|
|> -----Original Message-----
|> From: aspectj-users-admin@xxxxxxxxxxx [mailto:aspectj-users-
|> admin@xxxxxxxxxxx] On Behalf Of Sebastian Berger
|> Sent: Friday, February 04, 2005 10:01 AM
|> To: aspectj-users@xxxxxxxxxxx
|> Subject: [aspectj-users] AspectJ and obfuscator
|>
|> Hi,
|>
|> I really have some big problems with writing an ant build file for an
|> application using an AspectJ aspect. The application is a J2ME project
and
|> that's why I need an abfuscator. I am using proguard as obfuscator and
|> since
|> 3 days I am now trying to write an ant file for building my project.
Cause
|> I
|> am relative new to writing ant-files by myself, maybe the solution of
the
|> problem is easy, but at the moment I don't see any way to solve my
|> problem...
|> So the problem is that I don't know which jars to include in the
|> obfuscation
|> process, cause when I try to start my application I always get an error
|> that
|> he cannon find class org/aspectj/lang/NoAspectBoundException. I tried
|> several things, like including aspectjtools.jar and aspectjrt.jar in
the
|> obfuscation-process, but none has any positive results on building... I
|> only
|> get millions of warnings, when I do this. So here is my actual
build-file
|> (I
|> am already using as compiler the ajc-compiler; as ant-task I am using
|> iajc):
|>
|> build.xml:
|> ---------------
|> <project name="biginteger" default="dist" basedir="..">
|>   <property name="project" value="biginteger"/>
|>   <property name="WTK.dir"  value="C:\Programme\WTK21"/>
|>   <property name="MIDP.lib" value="${WTK.dir}\lib\midpapi20.jar"  />
|>   <property name="CLDC.lib" value="${WTK.dir}\lib\cldcapi11.jar" />
|>
|>   <property name="jdk.home"     value="C:\java\j2sdk" />
|>   <property name="ajc.home"     value="C:\Programme\aspectj" />
|>
|>   <!-- The following property is needed only for
obufscate_proguard. -->
|>   <property name="proguard"
|> value="c:\Programme\proguard\lib\proguard.jar"/>
|>
|>     <taskdef
|> resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
|>     </taskdef>
|>
|>   <path id="bootclasspath">
|>      <pathelement path="${MIDP.lib}"/>
|>      <pathelement path="${CLDC.lib}"/>
|>     </path>
|>
|>   <!-- The following property is only needs for the "tools"
|>        and "jad" targets. -->
|>   <property name="ant" value="C:\Programme\apache_ant"/>
|>
|>   <path id="ajc.classpath">
|>       <pathelement location="${ajc.home}/lib/aspectjrt.jar" />
|>       <pathelement location="${ajc.home}/lib/aspectjtools.jar" />
|>       <pathelement location="${ajc.home}/lib/aspectj-ant.jar" />
|>       <pathelement location="${jdk.home}/lib/tools.jar" />
|>   </path>
|>
|>     <path id="app.classpath">
|>           <pathelement location="${CLDC.lib}" />
|>           <pathelement location="${MIDP.lib}" />
|>     </path>
|>
|>     <path id="app.crypt">
|>           <pathelement location="../lib/midp_classes.zip" />
|>     </path>
|>
|>   <property name="Aspect.lib" value="${ajc.home}/lib/aspectjrt.jar" />
|>
|>   <!-- Runs the application in the emulator. -->
|>   <target name="run">
|>     <exec executable="${WTK.dir}/bin/emulator">
|>       <arg line="-classpath build/bin/${project}.jar"/>
|>       <arg line="-Xdescriptor build/bin/${project}.jad"/>
|>     </exec>
|>   </target>
|>
|>   <!-- Adjusts the JAR size in the JAD. -->
|>   <target name="jad" depends="dist">
|>     <taskdef name="jad" classname="JarSizeFix"/>
|>     <jad jar="build/bin/${project}.jar"
jad="build/bin/${project}.jad"/>
|>   </target>
|>
|>   <!-- Packages the application -->
|>   <target name="dist" depends="preverify">
|>     <mkdir dir="build/bin"/>
|>     <jar basedir="build/preverified"
|>         jarfile="build/bin/${project}.jar"
|>         manifest="MANIFEST.MF">
|>     </jar>
|>     <copy file="${project}.jad"
|>         tofile="build/bin/${project}.jad"/>
|>   </target>
|>
|>   <!--
|>     This target runs the preverifier on the class files.
|>
|>     Change 'depends' attribute here to select obfuscation:
|>       obfuscate_proguard
|>       obfuscate_retroguard
|>       obfuscate_null
|>   -->
|>   <target name="preverify" depends="obfuscate_proguard">
|>     <mkdir dir="build/preverified"/>
|>     <exec executable="${WTK.dir}/bin/preverify">
|>       <arg line="-classpath ${MIDP.lib};${CLDC.lib}"/>
|>       <arg line="-d build/preverified"/>
|>       <arg line="build/obfuscated"/>
|>     </exec>
|>   </target>
|>
|>   <!-- Obufscates using ProGuard. -->
|>   <target name="obfuscate_proguard" depends="compile, copylib">
|>     <mkdir dir="build/proguard"/>
|>     <jar basedir="build/classes"
|>         jarfile="build/proguard/${project}-input.jar"/>
|>
|>     <java fork="yes" classname="proguard.ProGuard"
|>         classpath="${proguard}">
|>       <arg line="-libraryjars ${MIDP.lib};${CLDC.lib}"/>
|>       <arg line="-injars build/proguard/${project}-input.jar"/>
|>       <arg line="-outjar build/proguard/${project}-output.jar"/>
|>       <arg line="-keep 'public class * extends
|> javax.microedition.midlet.MIDlet'"/>
|>       <arg line="-defaultpackage"/>
|>       <arg line="-dontusemixedcaseclassnames"/>
|>     </java>
|>
|>     <mkdir dir="build/obfuscated"/>
|>     <unjar src="build/proguard/${project}-output.jar"
|>         dest="build/obfuscated"/>
|>   </target>
|>
|>   <!-- Unjars the library APIs in preparation for obfuscation. -->
|>   <target name="copylib" depends="init">
|>     <unjar src="lib/midp_classes.zip" dest="build/classes"/>
|>   </target>
|>
|>   <!-- Compiles the source code. -->
|>   <target name="compile" depends="init">
|>     <mkdir dir="build/classes"/>
|>         <iajc destdir="build/classes">
|>             <sourceroots>
|>          <pathelement location="src"/>
|>      </sourceroots>
|>         <classpath>
|>           <path refid="ajc.classpath"/>
|>           <path refid="app.classpath"/>
|>           <path refid="app.crypt"/>
|>         </classpath>
|>
|>  </iajc>
|>     </target>
|>
|>
|>   <!-- Builds the JarSizeFix Ant task and installs it
|>        in the Ant lib directory. -->
|>   <target name="tools">
|>     <mkdir dir="build/tools_classes"/>
|>     <javac destdir="build/tools_classes"
|>         srcdir="build/tools"
|>         target="1.1"/>
|>     <jar jarfile="${ant}/lib/wd-tools.jar">
|>       <fileset dir="build/tools_classes"/>
|>     </jar>
|>     <delete dir="build/tools_classes"/>
|>   </target>
|>
|>   <target name="init">
|>     <tstamp/>
|>   </target>
|>
|> </project>
|> -------------------------------------------------------
|>
|> As result of starting this build.xml file with ant, I get the following
|> result:
|> -----------------------------
|> Buildfile: build.xml
|>
|> init:
|>
|> compile:
|>     [mkdir] Created dir:
D:\Programmierung\studi\biginteger\build\classes
|>
|> copylib:
|>     [unjar] Expanding:
|> D:\Programmierung\studi\biginteger\lib\midp_classes.zip i
|> nto D:\Programmierung\studi\biginteger\build\classes
|>
|> obfuscate_proguard:
|>     [mkdir] Created dir:
D:\Programmierung\studi\biginteger\build\proguard
|>       [jar] Building jar:
|> D:\Programmierung\studi\biginteger\build\proguard\bigi
|> nteger-input.jar
|>      [java] ProGuard, version 3.2
|>      [java] Reading program jar [build/proguard/biginteger-input.jar]
|>      [java] Reading library jar [C:\Programme\WTK21\lib\midpapi20.jar]
|>      [java] Reading library jar [C:\Programme\WTK21\lib\cldcapi11.jar]
|>      [java] Preparing output jar [build/proguard/biginteger-output.jar]
|>      [java] Copying resources from program jar
|> [build/proguard/biginteger-input.
|> jar]
|>     [mkdir] Created dir:
|> D:\Programmierung\studi\biginteger\build\obfuscated
|>     [unjar] Expanding:
|> D:\Programmierung\studi\biginteger\build\proguard\biginte
|> ger-output.jar into D:\Programmierung\studi\biginteger\build\obfuscated
|>
|> preverify:
|>     [mkdir] Created dir:
|> D:\Programmierung\studi\biginteger\build\preverified
|>      [exec] Error preverifying class c
|>      [exec]     VERIFIER ERROR c.b()Lc;:
|>      [exec] Cannot find class org/aspectj/lang/NoAspectBoundException
|>      [exec] Result: 1
|>
|> dist:
|>       [jar] Building jar:
|> D:\Programmierung\studi\biginteger\build\bin\bigintege
|> r.jar
|>
|> jad:
|>       [jad] MIDlet-Jar-Size: 30230
|>
|> BUILD SUCCESSFUL
|> -----------------------------------------
|>
|> So the j2me preverifier tells me that he couldn't find the class:
|> org/aspectj/lang/NoAspectBoundException
|>
|> I really don't know how to solve the problem, so for any hints I would
be
|> sooooo thankful and happy, cause I am really getting depressed with
this.
|>
|> Thanks in advance,
|> Sebastian
|>
|>
|> _______________________________________________
|> aspectj-users mailing list
|> aspectj-users@xxxxxxxxxxx
|> http://dev.eclipse.org/mailman/listinfo/aspectj-users
|
|
|
| _______________________________________________
| aspectj-users mailing list
| aspectj-users@xxxxxxxxxxx
| http://dev.eclipse.org/mailman/listinfo/aspectj-users
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCBfc3TTDTje0R2dgRAvvSAJ4uvFUfRRsz2witItAXaIkGmtQZfgCfZV3P
Rjfw05fSPegimY9C9HRe2Vo=
=JYCX
-----END PGP SIGNATURE-----
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users





Back to the top