org-netbeans-modules-profiler-oql

16:40:06.223 INFO  jd.cli.Main - Decompiling org-netbeans-modules-profiler-oql.jar
package org.netbeans.modules.profiler.oql.engine.api;

public abstract class OQLEngine$OQLQuery {}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.OQLEngine.OQLQuery
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api;

import java.util.logging.Level;
import java.util.logging.Logger;

final class OQLEngine$ObjectVisitor$1
  implements OQLEngine.ObjectVisitor
{
  public boolean visit(Object paramObject)
  {
    if ((paramObject != null) && (OQLEngine.access$000().isLoggable(Level.FINEST))) {
      OQLEngine.access$000().finest(paramObject.toString());
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.OQLEngine.ObjectVisitor.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api;

import java.util.logging.Level;
import java.util.logging.Logger;

public abstract interface OQLEngine$ObjectVisitor
{
  public static final ObjectVisitor DEFAULT = new ObjectVisitor()
  {
    public boolean visit(Object paramAnonymousObject)
    {
      if ((paramAnonymousObject != null) && (OQLEngine.access$000().isLoggable(Level.FINEST))) {
        OQLEngine.access$000().finest(paramAnonymousObject.toString());
      }
      return true;
    }
  };
  
  public abstract boolean visit(Object paramObject);
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.OQLEngine.ObjectVisitor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.lib.profiler.heap.Heap;
import org.netbeans.modules.profiler.oql.engine.api.impl.OQLEngineImpl;
import org.netbeans.modules.profiler.oql.engine.api.impl.Snapshot;

public class OQLEngine
{
  private static final Logger LOGGER = Logger.getLogger(OQLEngine.class.getName());
  private final OQLEngineImpl delegate;
  private final Heap heap;
  
  public static abstract interface ObjectVisitor
  {
    public static final ObjectVisitor DEFAULT = new ObjectVisitor()
    {
      public boolean visit(Object paramAnonymousObject)
      {
        if ((paramAnonymousObject != null) && (OQLEngine.LOGGER.isLoggable(Level.FINEST))) {
          OQLEngine.LOGGER.finest(paramAnonymousObject.toString());
        }
        return true;
      }
    };
    
    public abstract boolean visit(Object paramObject);
  }
  
  public static boolean isOQLSupported()
  {
    return OQLEngineImpl.isOQLSupported();
  }
  
  public OQLEngine(Heap paramHeap)
  {
    delegate = new OQLEngineImpl(new Snapshot(paramHeap));
    heap = paramHeap;
  }
  
  public Heap getHeap()
  {
    return heap;
  }
  
  public void executeQuery(String paramString, ObjectVisitor paramObjectVisitor)
    throws OQLException
  {
    delegate.executeQuery(paramString, paramObjectVisitor);
  }
  
  public OQLQuery parseQuery(String paramString)
    throws OQLException
  {
    return delegate.parseQuery(paramString);
  }
  
  public static abstract class OQLQuery {}
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.OQLEngine
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api;

public final class OQLException
  extends Exception
{
  public OQLException(String paramString)
  {
    super(paramString);
  }
  
  public OQLException(String paramString, Throwable paramThrowable)
  {
    super(paramString, paramThrowable);
  }
  
  public OQLException(Throwable paramThrowable)
  {
    super(paramThrowable);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.OQLException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api;

import org.netbeans.lib.profiler.heap.Instance;

public final class ReferenceChain
{
  Instance obj;
  ReferenceChain next;
  
  public ReferenceChain(Instance paramInstance, ReferenceChain paramReferenceChain)
  {
    obj = paramInstance;
    next = paramReferenceChain;
  }
  
  public Instance getObj()
  {
    return obj;
  }
  
  public ReferenceChain getNext()
  {
    return next;
  }
  
  public int getDepth()
  {
    int i = 1;
    ReferenceChain localReferenceChain = next;
    while (localReferenceChain != null)
    {
      i++;
      localReferenceChain = next;
    }
    return i;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.ReferenceChain
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.Bindings;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import org.netbeans.lib.profiler.heap.Instance;
import org.netbeans.lib.profiler.heap.JavaClass;
import org.netbeans.modules.profiler.oql.engine.api.OQLEngine.OQLQuery;
import org.netbeans.modules.profiler.oql.engine.api.OQLEngine.ObjectVisitor;
import org.netbeans.modules.profiler.oql.engine.api.OQLException;

public class OQLEngineImpl
{
  private static final Logger LOGGER = Logger.getLogger(OQLEngineImpl.class.getName());
  private static boolean oqlSupported;
  private ScriptEngine engine;
  private Snapshot snapshot;
  
  static
  {
    try
    {
      ScriptEngineManager localScriptEngineManager = new ScriptEngineManager();
      ScriptEngine localScriptEngine = localScriptEngineManager.getEngineByName("JavaScript");
      
      oqlSupported = localScriptEngine != null;
    }
    catch (Throwable localThrowable)
    {
      LOGGER.log(Level.INFO, "OQLEngine init", localThrowable);
      oqlSupported = false;
    }
  }
  
  public static boolean isOQLSupported()
  {
    return oqlSupported;
  }
  
  public OQLEngineImpl(Snapshot paramSnapshot)
  {
    if (!isOQLSupported()) {
      throw new UnsupportedOperationException("OQL not supported");
    }
    init(paramSnapshot);
  }
  
  public Snapshot getHeapHelper()
  {
    return snapshot;
  }
  
  public synchronized void executeQuery(String paramString, OQLEngine.ObjectVisitor paramObjectVisitor)
    throws OQLException
  {
    LOGGER.log(Level.FINE, paramString);
    
    OQLEngine.OQLQuery localOQLQuery = parseQuery(paramString);
    if (localOQLQuery == null)
    {
      try
      {
        Object localObject = evalScript(paramString);
        dispatchValue(localObject, paramObjectVisitor);
      }
      catch (Exception localException)
      {
        throw new OQLException(localException);
      }
      return;
    }
    executeQuery((OQLQueryImpl)localOQLQuery, paramObjectVisitor);
  }
  
  public OQLEngine.OQLQuery parseQuery(String paramString)
    throws OQLException
  {
    StringTokenizer localStringTokenizer = new StringTokenizer(paramString);
    if (localStringTokenizer.hasMoreTokens())
    {
      str1 = localStringTokenizer.nextToken();
      if (!str1.equals("select")) {
        return null;
      }
    }
    else
    {
      throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_NO_SELECT_CLAUSE"));
    }
    String str1 = "";
    int i = 0;
    while (localStringTokenizer.hasMoreTokens())
    {
      localObject = localStringTokenizer.nextToken();
      if (((String)localObject).equals("from"))
      {
        i = 1;
        break;
      }
      str1 = str1 + " " + (String)localObject;
    }
    if (str1.equals("")) {
      throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_EMPTY_SELECT"));
    }
    Object localObject = null;
    boolean bool = false;
    String str2 = null;
    String str3 = null;
    if (i != 0)
    {
      String str4;
      if (localStringTokenizer.hasMoreTokens())
      {
        str4 = localStringTokenizer.nextToken();
        if (str4.equals("instanceof"))
        {
          bool = true;
          if (!localStringTokenizer.hasMoreTokens()) {
            throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_INSTANCEOF_NO_CLASSNAME"));
          }
          localObject = localStringTokenizer.nextToken();
        }
        else
        {
          localObject = str4;
        }
      }
      else
      {
        throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_FROM_NO_CLASSNAME"));
      }
      if (localStringTokenizer.hasMoreTokens())
      {
        str3 = localStringTokenizer.nextToken();
        if (str3.equals("where")) {
          throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_NO_IDENTIFIER"));
        }
        if (localStringTokenizer.hasMoreTokens())
        {
          str4 = localStringTokenizer.nextToken();
          if (!str4.equals("where")) {
            throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_EXPECTING_WHERE"));
          }
          str2 = "";
          while (localStringTokenizer.hasMoreTokens()) {
            str2 = str2 + " " + localStringTokenizer.nextToken();
          }
          if (str2.equals("")) {
            throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_EMPTY_WHERE"));
          }
        }
      }
      else
      {
        throw new OQLException(ResourceBundle.getBundle("org/netbeans/modules/profiler/oql/engine/api/impl/Bundle").getString("ERROR_NO_IDENTIFIER"));
      }
    }
    return new OQLQueryImpl(str1, bool, (String)localObject, str3, str2);
  }
  
  private void executeQuery(OQLQueryImpl paramOQLQueryImpl, OQLEngine.ObjectVisitor paramObjectVisitor)
    throws OQLException
  {
    paramObjectVisitor = paramObjectVisitor != null ? paramObjectVisitor : OQLEngine.ObjectVisitor.DEFAULT;
    
    JavaClass localJavaClass1 = null;
    if (className != null)
    {
      localObject1 = className;
      
      localJavaClass1 = snapshot.findClass((String)localObject1);
      if (localJavaClass1 == null) {
        throw new OQLException((String)localObject1 + " is not found!");
      }
    }
    Object localObject1 = new StringBuffer();
    ((StringBuffer)localObject1).append("function __select__(");
    if (identifier != null) {
      ((StringBuffer)localObject1).append(identifier);
    }
    ((StringBuffer)localObject1).append(") { return ");
    ((StringBuffer)localObject1).append(selectExpr.replace('\n', ' '));
    ((StringBuffer)localObject1).append("; }\n");
    ((StringBuffer)localObject1).append("__select__(" + identifier + ")");
    
    String str = ((StringBuffer)localObject1).toString();
    try
    {
      Bindings localBindings = engine.getBindings(100);
      
      CompiledScript localCompiledScript1 = null;
      CompiledScript localCompiledScript2 = null;
      localCompiledScript2 = ((Compilable)engine).compile(str);
      if (whereExpr != null) {
        localCompiledScript1 = ((Compilable)engine).compile(whereExpr.replace('\n', ' '));
      }
      Object localObject2;
      if (className != null)
      {
        localObject2 = new Stack();
        HashSet localHashSet = new HashSet();
        
        ((Stack)localObject2).push(localJavaClass1);
        
        Object localObject3 = null;
        Object localObject5;
        while (!((Stack)localObject2).isEmpty())
        {
          localObject3 = ((Stack)localObject2).pop();
          localHashSet.add(localObject3);
          JavaClass localJavaClass2 = (JavaClass)localObject3;
          if (isInstanceOf) {
            for (localObject4 = localJavaClass2.getSubClasses().iterator(); ((Iterator)localObject4).hasNext();)
            {
              localObject5 = ((Iterator)localObject4).next();
              if ((!localHashSet.contains(localObject5)) && (!((Stack)localObject2).contains(localObject5))) {
                ((Stack)localObject2).push(localObject5);
              }
            }
          }
          Object localObject4 = localJavaClass2.getInstances();
          for (localObject5 = ((List)localObject4).iterator(); ((Iterator)localObject5).hasNext();)
          {
            Object localObject6 = ((Iterator)localObject5).next();
            Object localObject7 = wrapJavaObject((Instance)localObject6);
            boolean bool = localCompiledScript1 == null;
            Object localObject8;
            if (!bool)
            {
              localBindings.put(identifier, localObject7);
              localObject8 = localCompiledScript1.eval(localBindings);
              if ((localObject8 instanceof Boolean)) {
                bool = ((Boolean)localObject8).booleanValue();
              } else if ((localObject8 instanceof Number)) {
                bool = ((Number)localObject8).intValue() != 0;
              } else {
                bool = localObject8 != null;
              }
            }
            if (bool)
            {
              localBindings.put(identifier, localObject7);
              localObject8 = localCompiledScript2.eval(localBindings);
              if (dispatchValue(localObject8, paramObjectVisitor)) {
                return;
              }
            }
          }
        }
      }
      else
      {
        localObject2 = localCompiledScript2.eval();
        if (dispatchValue(localObject2, paramObjectVisitor)) {
          return;
        }
      }
    }
    catch (Exception localException)
    {
      throw new OQLException(localException);
    }
  }
  
  private boolean dispatchValue(Object paramObject, OQLEngine.ObjectVisitor paramObjectVisitor)
  {
    if (paramObject == null) {
      return false;
    }
    if ((paramObject instanceof Iterator))
    {
      localObject1 = (Iterator)paramObject;
      while (((Iterator)localObject1).hasNext()) {
        if (dispatchValue(((Iterator)localObject1).next(), paramObjectVisitor)) {
          return true;
        }
      }
      return false;
    }
    Object localObject2;
    if ((paramObject instanceof Enumeration))
    {
      localObject1 = (Enumeration)paramObject;
      while (((Enumeration)localObject1).hasMoreElements())
      {
        localObject2 = ((Enumeration)localObject1).nextElement();
        if (dispatchValue(localObject2, paramObjectVisitor)) {
          return true;
        }
      }
      return false;
    }
    Object localObject1 = unwrapJavaObject(paramObject, true);
    if ((localObject1 instanceof Object[]))
    {
      for (Object localObject3 : (Object[])localObject1) {
        if (dispatchValue(localObject3, paramObjectVisitor)) {
          return true;
        }
      }
      return false;
    }
    if (paramObjectVisitor.visit(localObject1)) {
      return true;
    }
    return false;
  }
  
  public Object evalScript(String paramString)
    throws Exception
  {
    CompiledScript localCompiledScript = ((Compilable)engine).compile(paramString);
    return localCompiledScript.eval();
  }
  
  public Object wrapJavaObject(Instance paramInstance)
    throws Exception
  {
    return call("wrapJavaObject", new Object[] { paramInstance });
  }
  
  public Object toHtml(Object paramObject)
    throws Exception
  {
    return call("toHtml", new Object[] { paramObject });
  }
  
  public Object call(String paramString, Object[] paramArrayOfObject)
    throws Exception
  {
    return ((Invocable)engine).invokeFunction(paramString, paramArrayOfObject);
  }
  
  public Object unwrapJavaObject(Object paramObject)
  {
    return unwrapJavaObject(paramObject, false);
  }
  
  public Object unwrapJavaObject(Object paramObject, boolean paramBoolean)
  {
    if (paramObject == null) {
      return null;
    }
    boolean bool = paramObject.getClass().getName().contains(".javascript.");
    try
    {
      Object localObject = ((Invocable)engine).invokeFunction("unwrapJavaObject", new Object[] { paramObject });
      if ((bool) && ((localObject == null) || (localObject == paramObject)) && (paramBoolean)) {}
      return ((Invocable)engine).invokeFunction("unwrapMap", new Object[] { paramObject });
    }
    catch (Exception localException)
    {
      LOGGER.log(Level.WARNING, "Error unwrapping JS object", localException);
    }
    return null;
  }
  
  private void init(Snapshot paramSnapshot)
    throws RuntimeException
  {
    snapshot = paramSnapshot;
    try
    {
      ScriptEngineManager localScriptEngineManager = new ScriptEngineManager();
      engine = localScriptEngineManager.getEngineByName("JavaScript");
      InputStream localInputStream = getInitStream();
      CompiledScript localCompiledScript = ((Compilable)engine).compile(new InputStreamReader(localInputStream));
      localCompiledScript.eval();
      Object localObject = ((Invocable)engine).invokeFunction("wrapHeapSnapshot", new Object[] { paramSnapshot });
      engine.put("heap", localObject);
    }
    catch (Exception localException)
    {
      LOGGER.log(Level.SEVERE, "Error initializing snapshot", localException);
      throw new RuntimeException(localException);
    }
  }
  
  private InputStream getInitStream()
  {
    return getClass().getResourceAsStream("/org/netbeans/modules/profiler/oql/engine/api/impl/hat.js");
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.OQLEngineImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import org.netbeans.modules.profiler.oql.engine.api.OQLEngine.OQLQuery;

public class OQLQueryImpl
  extends OQLEngine.OQLQuery
{
  String selectExpr;
  boolean isInstanceOf;
  String className;
  String identifier;
  String whereExpr;
  
  OQLQueryImpl(String paramString1, boolean paramBoolean, String paramString2, String paramString3, String paramString4)
  {
    selectExpr = paramString1;
    isInstanceOf = paramBoolean;
    className = paramString2;
    identifier = paramString3;
    whereExpr = paramString4;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.OQLQueryImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

public abstract interface ReachableExcludes
{
  public abstract boolean isExcluded(String paramString);
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.ReachableExcludes
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.netbeans.lib.profiler.heap.FieldValue;
import org.netbeans.lib.profiler.heap.Instance;
import org.netbeans.lib.profiler.heap.ObjectArrayInstance;
import org.netbeans.lib.profiler.heap.ObjectFieldValue;

class ReachableObjects$1
  extends TreeIterator<Instance, Instance>
{
  ReachableObjects$1(ReachableObjects paramReachableObjects, Instance paramInstance)
  {
    super(paramInstance);
  }
  
  protected Iterator<Instance> getSameLevelIterator(Instance paramInstance)
  {
    ArrayList localArrayList = new ArrayList();
    for (Object localObject : paramInstance.getFieldValues()) {
      if (((localObject instanceof ObjectFieldValue)) && (
        (ReachableObjects.access$000(this$0) == null) || (!ReachableObjects.access$000(this$0).isExcluded(ReachableObjects.access$100(this$0, ((FieldValue)localObject).getField())))))
      {
        Instance localInstance = ((ObjectFieldValue)localObject).getInstance();
        if (localInstance != null) {
          localArrayList.add(localInstance);
        }
      }
    }
    if ((paramInstance instanceof ObjectArrayInstance)) {
      localArrayList.addAll(((ObjectArrayInstance)paramInstance).getValues());
    }
    return localArrayList.iterator();
  }
  
  protected Iterator<Instance> getTraversingIterator(Instance paramInstance)
  {
    ArrayList localArrayList = new ArrayList();
    for (Object localObject : paramInstance.getFieldValues()) {
      if (((localObject instanceof ObjectFieldValue)) && (
        (ReachableObjects.access$000(this$0) == null) || (!ReachableObjects.access$000(this$0).isExcluded(ReachableObjects.access$100(this$0, ((FieldValue)localObject).getField())))))
      {
        Instance localInstance = ((ObjectFieldValue)localObject).getInstance();
        if (localInstance != null) {
          localArrayList.add(localInstance);
        }
      }
    }
    if ((paramInstance instanceof ObjectArrayInstance)) {
      localArrayList.addAll(((ObjectArrayInstance)paramInstance).getValues());
    }
    return localArrayList.iterator();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.ReachableObjects.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.netbeans.lib.profiler.heap.Field;
import org.netbeans.lib.profiler.heap.FieldValue;
import org.netbeans.lib.profiler.heap.Instance;
import org.netbeans.lib.profiler.heap.JavaClass;
import org.netbeans.lib.profiler.heap.ObjectArrayInstance;
import org.netbeans.lib.profiler.heap.ObjectFieldValue;

public class ReachableObjects
{
  private ReachableExcludes excludes;
  private Instance root;
  
  public ReachableObjects(Instance paramInstance, ReachableExcludes paramReachableExcludes)
  {
    root = paramInstance;
    excludes = paramReachableExcludes;
  }
  
  public Instance getRoot()
  {
    return root;
  }
  
  public Iterator<Instance> getReachables()
  {
    new TreeIterator(root)
    {
      protected Iterator<Instance> getSameLevelIterator(Instance paramAnonymousInstance)
      {
        ArrayList localArrayList = new ArrayList();
        for (Object localObject : paramAnonymousInstance.getFieldValues()) {
          if (((localObject instanceof ObjectFieldValue)) && (
            (excludes == null) || (!excludes.isExcluded(ReachableObjects.this.getFQFieldName(((FieldValue)localObject).getField())))))
          {
            Instance localInstance = ((ObjectFieldValue)localObject).getInstance();
            if (localInstance != null) {
              localArrayList.add(localInstance);
            }
          }
        }
        if ((paramAnonymousInstance instanceof ObjectArrayInstance)) {
          localArrayList.addAll(((ObjectArrayInstance)paramAnonymousInstance).getValues());
        }
        return localArrayList.iterator();
      }
      
      protected Iterator<Instance> getTraversingIterator(Instance paramAnonymousInstance)
      {
        ArrayList localArrayList = new ArrayList();
        for (Object localObject : paramAnonymousInstance.getFieldValues()) {
          if (((localObject instanceof ObjectFieldValue)) && (
            (excludes == null) || (!excludes.isExcluded(ReachableObjects.this.getFQFieldName(((FieldValue)localObject).getField())))))
          {
            Instance localInstance = ((ObjectFieldValue)localObject).getInstance();
            if (localInstance != null) {
              localArrayList.add(localInstance);
            }
          }
        }
        if ((paramAnonymousInstance instanceof ObjectArrayInstance)) {
          localArrayList.addAll(((ObjectArrayInstance)paramAnonymousInstance).getValues());
        }
        return localArrayList.iterator();
      }
    };
  }
  
  public long getTotalSize()
  {
    return -1L;
  }
  
  private String getFQFieldName(Field paramField)
  {
    return paramField.getDeclaringClass().getName() + "." + paramField.getName();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.ReachableObjects
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import java.util.Iterator;
import org.netbeans.lib.profiler.heap.JavaClass;

class Snapshot$1
  implements Iterator
{
  Snapshot$1(Snapshot paramSnapshot, Iterator paramIterator) {}
  
  public boolean hasNext()
  {
    return val$delegated.hasNext();
  }
  
  public Object next()
  {
    return ((JavaClass)val$delegated.next()).getName();
  }
  
  public void remove()
  {
    val$delegated.remove();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.Snapshot.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.netbeans.lib.profiler.heap.Instance;
import org.netbeans.lib.profiler.heap.JavaClass;

class Snapshot$2
  extends TreeIterator<Instance, JavaClass>
{
  Snapshot$2(Snapshot paramSnapshot, JavaClass paramJavaClass, boolean paramBoolean)
  {
    super(paramJavaClass);
  }
  
  protected Iterator<Instance> getSameLevelIterator(JavaClass paramJavaClass)
  {
    return paramJavaClass.getInstances().iterator();
  }
  
  protected Iterator<JavaClass> getTraversingIterator(JavaClass paramJavaClass)
  {
    return val$includeSubclasses ? paramJavaClass.getSubClasses().iterator() : Collections.EMPTY_LIST.iterator();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.Snapshot.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.lib.profiler.heap.Field;
import org.netbeans.lib.profiler.heap.FieldValue;
import org.netbeans.lib.profiler.heap.GCRoot;
import org.netbeans.lib.profiler.heap.Heap;
import org.netbeans.lib.profiler.heap.Instance;
import org.netbeans.lib.profiler.heap.JavaClass;
import org.netbeans.lib.profiler.heap.ObjectFieldValue;
import org.netbeans.lib.profiler.heap.PrimitiveArrayInstance;
import org.netbeans.lib.profiler.heap.Value;
import org.netbeans.modules.profiler.oql.engine.api.ReferenceChain;

public class Snapshot
{
  private final Heap delegate;
  private JavaClass weakReferenceClass;
  private int referentFieldIndex;
  private ReachableExcludes reachableExcludes;
  
  public Snapshot(Heap paramHeap)
  {
    delegate = paramHeap;
    init();
  }
  
  private void init()
  {
    weakReferenceClass = findClass("java.lang.ref.Reference");
    if (weakReferenceClass == null)
    {
      weakReferenceClass = findClass("sun.misc.Ref");
      referentFieldIndex = 0;
    }
    else
    {
      List localList = weakReferenceClass.getFields();
      int i = localList.size();
      for (int j = 0; j < i; j++) {
        if ("referent".equals(((Field)localList.get(j)).getName()))
        {
          referentFieldIndex = j;
          break;
        }
      }
    }
  }
  
  public int getMinimumObjectSize()
  {
    return 4;
  }
  
  public JavaClass findClass(String paramString)
  {
    try
    {
      long l;
      if (paramString.startsWith("0x")) {
        l = Long.parseLong(paramString.substring(2), 16);
      } else {
        l = Long.parseLong(paramString);
      }
      return delegate.getJavaClassByID(l);
    }
    catch (NumberFormatException localNumberFormatException) {}
    return delegate.getJavaClassByName(preprocessClassName(paramString));
  }
  
  private String preprocessClassName(String paramString)
  {
    int i = 0;
    if (paramString.startsWith("["))
    {
      i = paramString.lastIndexOf("[") + 1;
      
      paramString = paramString.substring(i);
    }
    if (paramString.length() == 1) {
      if (paramString.equals("I")) {
        paramString = "int";
      } else if (paramString.equals("J")) {
        paramString = "long";
      } else if (paramString.equals("D")) {
        paramString = "double";
      } else if (paramString.equals("F")) {
        paramString = "float";
      } else if (paramString.equals("B")) {
        paramString = "byte";
      } else if (paramString.equals("S")) {
        paramString = "short";
      } else if (paramString.equals("C")) {
        paramString = "char";
      } else if (paramString.equals("Z")) {
        paramString = "boolean";
      }
    }
    if ((i > 0) && (paramString.startsWith("L"))) {
      paramString = paramString.substring(1);
    }
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    for (int j = 0; j < i; j++) {
      localStringBuilder.append("[]");
    }
    return localStringBuilder.toString();
  }
  
  public Instance findThing(long paramLong)
  {
    return delegate.getInstanceByID(paramLong);
  }
  
  public GCRoot findRoot(Instance paramInstance)
  {
    Instance localInstance = paramInstance;
    do
    {
      localInstance = localInstance.getNearestGCRootPointer();
    } while (!localInstance.isGCRoot());
    if (localInstance != null) {
      return delegate.getGCRoot(localInstance);
    }
    return null;
  }
  
  public Iterator getClasses()
  {
    return delegate.getAllClasses().iterator();
  }
  
  public Iterator getClassNames(String paramString)
  {
    final Iterator localIterator = delegate.getJavaClassesByRegExp(paramString).iterator();
    new Iterator()
    {
      public boolean hasNext()
      {
        return localIterator.hasNext();
      }
      
      public Object next()
      {
        return ((JavaClass)localIterator.next()).getName();
      }
      
      public void remove()
      {
        localIterator.remove();
      }
    };
  }
  
  public Iterator getInstances(JavaClass paramJavaClass, final boolean paramBoolean)
  {
    new TreeIterator(paramJavaClass)
    {
      protected Iterator<Instance> getSameLevelIterator(JavaClass paramAnonymousJavaClass)
      {
        return paramAnonymousJavaClass.getInstances().iterator();
      }
      
      protected Iterator<JavaClass> getTraversingIterator(JavaClass paramAnonymousJavaClass)
      {
        return paramBoolean ? paramAnonymousJavaClass.getSubClasses().iterator() : Collections.EMPTY_LIST.iterator();
      }
    };
  }
  
  public Iterator getReferrers(Instance paramInstance)
  {
    ArrayList localArrayList = new ArrayList();
    List localList = null;
    localList = paramInstance.getReferences();
    Iterator localIterator;
    if (localList != null) {
      for (localIterator = localList.iterator(); localIterator.hasNext();)
      {
        Value localValue = (Value)localIterator.next();
        localArrayList.add(localValue.getDefiningInstance());
      }
    }
    return localArrayList.iterator();
  }
  
  public Iterator getReferees(Object paramObject)
  {
    ArrayList localArrayList = new ArrayList();
    List localList = null;
    if ((paramObject instanceof Instance)) {
      localList = ((Instance)paramObject).getFieldValues();
    } else if ((paramObject instanceof JavaClass)) {
      localList = ((JavaClass)paramObject).getStaticFieldValues();
    }
    if (localList != null) {
      for (Object localObject : localList) {
        if ((localObject instanceof ObjectFieldValue)) {
          localArrayList.add(((ObjectFieldValue)localObject).getInstance());
        }
      }
    }
    return localArrayList.iterator();
  }
  
  public Iterator getReferees(JavaClass paramJavaClass)
  {
    ArrayList localArrayList = new ArrayList();
    for (Object localObject : paramJavaClass.getStaticFieldValues()) {
      if ((localObject instanceof ObjectFieldValue)) {
        localArrayList.add(((ObjectFieldValue)localObject).getInstance());
      }
    }
    return localArrayList.iterator();
  }
  
  public JavaClass[] getClassesArray()
  {
    return (JavaClass[])delegate.getAllClasses().toArray();
  }
  
  public Iterator getFinalizerObjects()
  {
    JavaClass localJavaClass = findClass("java.lang.ref.Finalizer");
    Instance localInstance1 = ((ObjectFieldValue)localJavaClass.getValueOfStaticField("queue")).getInstance();
    ObjectFieldValue localObjectFieldValue1 = (ObjectFieldValue)localInstance1.getValueOfField("head");
    
    ArrayList localArrayList = new ArrayList();
    if (localObjectFieldValue1 != null)
    {
      Instance localInstance2 = localObjectFieldValue1.getInstance();
      for (;;)
      {
        ObjectFieldValue localObjectFieldValue2 = (ObjectFieldValue)localInstance2.getValueOfField("referent");
        ObjectFieldValue localObjectFieldValue3 = (ObjectFieldValue)localInstance2.getValueOfField("next");
        if ((localObjectFieldValue3 == null) || (localObjectFieldValue3.getInstance().equals(localInstance2))) {
          break;
        }
        localInstance2 = localObjectFieldValue3.getInstance();
        localArrayList.add(localObjectFieldValue2.getInstance());
      }
    }
    return localArrayList.iterator();
  }
  
  public Iterator getRoots()
  {
    return delegate.getGCRoots().iterator();
  }
  
  public GCRoot[] getRootsArray()
  {
    return (GCRoot[])delegate.getGCRoots().toArray();
  }
  
  public ReferenceChain[] rootsetReferencesTo(Instance paramInstance, boolean paramBoolean)
  {
    LinkedList localLinkedList = new LinkedList();
    
    HashMap localHashMap = new HashMap();
    
    ArrayList localArrayList = new ArrayList();
    localHashMap.put(paramInstance, paramInstance);
    localLinkedList.add(new ReferenceChain(paramInstance, null));
    
    ReferenceChain localReferenceChain = null;
    Instance localInstance1;
    do
    {
      localReferenceChain = (ReferenceChain)localLinkedList.poll();
      if (localReferenceChain != null)
      {
        localInstance1 = localReferenceChain.getObj();
        if (localInstance1.isGCRoot()) {
          localArrayList.add(localReferenceChain);
        }
        List localList = getReferers(localInstance1);
        for (Instance localInstance2 : localList) {
          if ((localInstance2 != null) && (!localHashMap.containsKey(localInstance2)) && (
            (paramBoolean) || (!refersOnlyWeaklyTo(localInstance2, localInstance1))))
          {
            localHashMap.put(localInstance2, localInstance2);
            localLinkedList.add(new ReferenceChain(localInstance2, localReferenceChain));
          }
        }
      }
    } while (localReferenceChain != null);
    return (ReferenceChain[])localArrayList.toArray(new ReferenceChain[localArrayList.size()]);
  }
  
  private List<Instance> getReferers(Instance paramInstance)
  {
    ArrayList localArrayList = new ArrayList();
    for (Object localObject : paramInstance.getReferences()) {
      if ((localObject instanceof Value)) {
        localArrayList.add(((Value)localObject).getDefiningInstance());
      }
    }
    return localArrayList;
  }
  
  private boolean refersOnlyWeaklyTo(Instance paramInstance1, Instance paramInstance2)
  {
    if ((getWeakReferenceClass() != null) && 
      (isAssignable(getWeakReferenceClass(), paramInstance1.getJavaClass())))
    {
      FieldValue[] arrayOfFieldValue = (FieldValue[])paramInstance1.getFieldValues().toArray();
      for (int i = 0; i < arrayOfFieldValue.length; i++) {
        if ((i != referentFieldIndex) && 
          ((arrayOfFieldValue[i] instanceof ObjectFieldValue)) && 
          (((ObjectFieldValue)arrayOfFieldValue[i]).getInstance() == paramInstance2)) {
          return false;
        }
      }
      return true;
    }
    return false;
  }
  
  private boolean isAssignable(JavaClass paramJavaClass1, JavaClass paramJavaClass2)
  {
    if (paramJavaClass1 == paramJavaClass2) {
      return true;
    }
    if (paramJavaClass1 == null) {
      return false;
    }
    return isAssignable(paramJavaClass1.getSuperClass(), paramJavaClass2);
  }
  
  public JavaClass getWeakReferenceClass()
  {
    return weakReferenceClass;
  }
  
  public int getReferentFieldIndex()
  {
    return referentFieldIndex;
  }
  
  public void setReachableExcludes(ReachableExcludes paramReachableExcludes)
  {
    reachableExcludes = paramReachableExcludes;
  }
  
  public ReachableExcludes getReachableExcludes()
  {
    return reachableExcludes;
  }
  
  public String valueString(Instance paramInstance)
  {
    if (paramInstance == null) {
      return null;
    }
    try
    {
      Object localObject1;
      Object localObject2;
      if (paramInstance.getJavaClass().getName().equals(String.class.getName()))
      {
        localObject1 = Class.forName("org.netbeans.lib.profiler.heap.HprofProxy");
        localObject2 = ((Class)localObject1).getDeclaredMethod("getString", new Class[] { Instance.class });
        ((Method)localObject2).setAccessible(true);
        return (String)((Method)localObject2).invoke(localObject1, new Object[] { paramInstance });
      }
      if (paramInstance.getJavaClass().getName().equals("char[]"))
      {
        localObject1 = paramInstance.getClass().getDeclaredMethod("getChars", new Class[] { Integer.TYPE, Integer.TYPE });
        ((Method)localObject1).setAccessible(true);
        localObject2 = (char[])((Method)localObject1).invoke(paramInstance, new Object[] { Integer.valueOf(0), Integer.valueOf(((PrimitiveArrayInstance)paramInstance).getLength()) });
        if (localObject2 != null) {
          return new String((char[])localObject2);
        }
        return "*null*";
      }
    }
    catch (Exception localException)
    {
      Logger.getLogger(Snapshot.class.getName()).log(Level.WARNING, "Error getting toString() value of an instance dump", localException);
    }
    return paramInstance.toString();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.profiler.oql.engine.api.impl.Snapshot
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.profiler.oql.engine.api.impl;

import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.Stack;

public abstract class TreeIterator<I, T>
  implements Iterator<I>
{
  private Stack<T> toInspect = new Stack();
  private Set<T> inspected = new HashSet();
  private T popped = null;
  private Iterator<I> inspecting = null;
  
  public TreeIterator(T paramT)
  {
    toInspect.push(paramT);
    inspected.add(paramT);
  }
  
  public boolean hasNext()
  {
    setupIterator();
    return (inspecting != null) && (inspecting.hasNext());
  }
  
  public I next()
  {
    setupIterator();
    if ((inspecting == null) || (!inspecting.hasNext())) {
      throw new NoSuchElementException();
    }
    Object localObject = inspecting.next();
    return (I)localObject;
  }
  
  public void remove()
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }
  
  protected abstract Iterator<I> getSameLevelIterator(T paramT);
  
  protected abstract Iterator<T> getTraversingIterator(T paramT);
  
  private void setupIterator()
  {
    while ((!toInspect.isEmpty()) && ((inspecting == null) || (!inspecting.hasNext())))
    {
      popped = toInspect.pop();
      if (popped != null)
      {
        inspecting = getSameLevelIterator(popped);
        Iterator localIterator = getTraversingIterator(popped);
        
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd