HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Preventing Reverse Engineering"
Vol. 9, Issue 5, p. 39

	



Listing 1: The add() method of the Queue class after decompilation

01 public synchronized void add
        (Object item) {
02   long addWaitTime = 0;
03   while (_suspended ||
            _tail == QUEUE_FULL) {
04     long waitStart =
        System.currentTimeMillis();
05     try {
06       wait();
07     } catch (InterruptedException e)
       {  }
08     addWaitTime +=
        (System.currentTimeMillis() -
          waitStart);
09   }
10   _addWaitTime += addWaitTime;
11   // add item to backing store
12   _backingStore[_tail] = item;
13   _queueEmpty = false;
14   _tail++;
15   if (_tail >= _backingStore.length)
16     _tail = 0; // wrap
17   if (_tail == _head) {
18     _tail = -1; // special case:full
19   }
20   _queueFull =
      (_tail == -1) ? true : false;
21   notifyAll();
22 }


Listing 2: The add() method of the Queue class

01 public synchronized void add
      (Object item) {
02   long addWaitTime = 0L;
03   while (_suspended || _tail == -1) {
04     long waitStart =
          System.currentTimeMillis();
05     try {
06       this.wait();
07     } catch (InterruptedException e){
08       /* empty */
09     }
10     addWaitTime +=
        System.currentTimeMillis() -
          waitStart;
11   }
12   _addWaitTime += addWaitTime;
13   _backingStore[_tail] = item;
14   _queueEmpty = false;
15   _tail++;
16   if (_tail >= _backingStore.length)
17     _tail = 0;
18   if (_tail == _head)
19     _tail = -1;
20   _queueFull = _tail == -1;
21   this.notifyAll();
22 }


Listing 3: The add() method of the Queue class after decompilation

01 public synchronized void add
      (Object object) {
02   long l = 0L;
03   while (_suspended || _tail == -1) {
04     long l_2_ =
        System.currentTimeMillis();
05     try {
06       this.wait();
07     } catch (InterruptedException e){
08       /* empty */
09     }
10     l += System.currentTimeMillis() -
         l_2_;
11   }
12   _addWaitTime += l;
13   _backingStore[_tail] = object;
14   _queueEmpty = false;
15   _tail++;
16   if (_tail >= _backingStore.length)
17   _tail = 0;
18   if (_tail == _head)
19     _tail = -1;
20   _queueFull = _tail == -1;
21   this.notifyAll();
22 }

Listing 4: Snippets from the map file produced by yGuard

public synchronized void A(Object obj) {
  long l;
  long l1;
  for(l = 0L; J || K == - 1; l +=
      System.currentTimeMillis() - l1) {
    l1 = System.currentTimeMillis();
    try {
      wait();
    } catch(InterruptedException i) { }
  }
  S += l;
  L[K] = obj;
  T = false;
  K++;
  if(K >= L.length) {
    K = 0;
  }
  if(K == O) {
    K = -1;
  }
  R = K == -1;
  notifyAll();
}





Listing 5: The add() method of the Queue class after first 
obfuscating the bytecode using yGuard
BEFORE. . . public class Queue extends Basic { private int _head; private int _tail; private Object _backingStore[]; private boolean _suspended; private boolean _queueFull; private boolean _queueEmpty; private ArrayList _suppliers; private ArrayList _consumers; private boolean _endOfInput; private long _addWaitTime; private long _removeWaitTime; private long _numberOfItemsProcessed; . . . } AFTER. . . public class C extends B { private int O; private int K; private Object L[]; private boolean J; private boolean R; private boolean T; private ArrayList N; private ArrayList P; private boolean U; private long S; private long H; private long Q; . . . } Listing 6 01<?xml version="1.0" encoding="UTF-8"?> 02<yguard version="1.1"> 03. . . 04<expose> 05 <class name="jmxbp.ex1.Controller"/> 06 <method class="jmxbp.ex1.Controller" name="void main(java.lang.String[])"/> 07. . . 08</expose> 09<map> 10 <package name="jmxbp.common" map="A"/> 11. . . 12 <class name="jmxbp.common.Basic" map="B"/> 13. . . 14 <class name="jmxbp.common.Queue" map="C"/> 15 <field class="jmxbp.common.Queue" name="_head" map="O"/> 16. . . 17 <method class="jmxbp.common.Queue" name="void add(java.lang.Object)" map="A"/> 18 <method class="jmxbp.common.Queue" name="java.lang.Object remove(long)" map="A"/> 19. . . 20</map> 21</yguard>
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.