org.eclipse.equinox.p2.repository.tools_2.0.100.v20110815-1438

16:44:25.081 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.repository.tools_2.0.100.v20110815-1438.jar
package org.eclipse.equinox.p2.internal.repository.comparator;

import org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry;

class JarComparator$FeatureEntryWrapper
{
  private FeatureEntry entry;
  
  public JarComparator$FeatureEntryWrapper(FeatureEntry entry)
  {
    this.entry = entry;
  }
  
  public boolean equals(Object o)
  {
    FeatureEntry otherEntry = (o instanceof FeatureEntryWrapper) ? ((FeatureEntryWrapper)o).getEntry() : null;
    if ((otherEntry == null) || (!entry.equals(otherEntry))) {
      return false;
    }
    String arch = otherEntry.getArch();
    if (arch == null ? entry.getArch() != null : !arch.equals(entry.getArch())) {
      return false;
    }
    String os = otherEntry.getOS();
    if (os == null ? entry.getOS() != null : !os.equals(entry.getOS())) {
      return false;
    }
    String ws = otherEntry.getWS();
    if (ws == null ? entry.getWS() != null : !ws.equals(entry.getWS())) {
      return false;
    }
    return true;
  }
  
  public int hashCode()
  {
    int hash = entry.hashCode();
    if (entry.getArch() != null) {
      hash += entry.getArch().hashCode();
    }
    if (entry.getOS() != null) {
      hash += entry.getOS().hashCode();
    }
    if (entry.getWS() != null) {
      hash += entry.getWS().hashCode();
    }
    return hash;
  }
  
  public FeatureEntry getEntry()
  {
    return entry;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.p2.internal.repository.comparator.JarComparator.FeatureEntryWrapper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.p2.internal.repository.comparator;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser;
import org.eclipse.equinox.p2.internal.repository.comparator.java.ClassFormatException;
import org.eclipse.equinox.p2.internal.repository.comparator.java.Disassembler;
import org.eclipse.equinox.p2.internal.repository.comparator.java.Messages;
import org.eclipse.equinox.p2.internal.repository.comparator.java.Utility;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.publisher.eclipse.Feature;
import org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.tools.comparator.IArtifactComparator;
import org.eclipse.osgi.util.NLS;

public class JarComparator
  implements IArtifactComparator
{
  private static final String LINE_SEPARATOR = "\n";
  private static final String CLASS_EXTENSION = ".class";
  private static final String JAR_EXTENSION = ".jar";
  private static final String PROPERTIES_EXTENSION = ".properties";
  private static final String MAPPINGS_EXTENSION = ".mappings";
  private static final String PLUGIN_ID = "org.eclipse.equinox.p2.repository.tools";
  private static final String DESTINATION_ARTIFACT_PREFIX = "destinationartifact";
  private static final String SUFFIX_JAR = ".jar";
  private static final String SOURCE_ARTIFACT_PREFIX = "sourceartifact";
  private static final String OSGI_BUNDLE_CLASSIFIER = "osgi.bundle";
  private static final String FEATURE_CLASSIFIER = "org.eclipse.update.feature";
  private static final String META_INF = "meta-inf/";
  private static final String DSA_EXT = ".dsa";
  private static final String RSA_EXT = ".rsa";
  private static final String SF_EXT = ".sf";
  private String sourceLocation;
  private String destinationLocation;
  private String descriptorString;
  
  private static class FeatureEntryWrapper
  {
    private FeatureEntry entry;
    
    public FeatureEntryWrapper(FeatureEntry entry)
    {
      this.entry = entry;
    }
    
    public boolean equals(Object o)
    {
      FeatureEntry otherEntry = (o instanceof FeatureEntryWrapper) ? ((FeatureEntryWrapper)o).getEntry() : null;
      if ((otherEntry == null) || (!entry.equals(otherEntry))) {
        return false;
      }
      String arch = otherEntry.getArch();
      if (arch == null ? entry.getArch() != null : !arch.equals(entry.getArch())) {
        return false;
      }
      String os = otherEntry.getOS();
      if (os == null ? entry.getOS() != null : !os.equals(entry.getOS())) {
        return false;
      }
      String ws = otherEntry.getWS();
      if (ws == null ? entry.getWS() != null : !ws.equals(entry.getWS())) {
        return false;
      }
      return true;
    }
    
    public int hashCode()
    {
      int hash = entry.hashCode();
      if (entry.getArch() != null) {
        hash += entry.getArch().hashCode();
      }
      if (entry.getOS() != null) {
        hash += entry.getOS().hashCode();
      }
      if (entry.getWS() != null) {
        hash += entry.getWS().hashCode();
      }
      return hash;
    }
    
    public FeatureEntry getEntry()
    {
      return entry;
    }
  }
  
  public IStatus compare(IArtifactRepository source, IArtifactDescriptor sourceDescriptor, IArtifactRepository destination, IArtifactDescriptor destinationDescriptor)
  {
    sourceLocation = URIUtil.toUnencodedString(sourceDescriptor.getRepository().getLocation());
    destinationLocation = URIUtil.toUnencodedString(destinationDescriptor.getRepository().getLocation());
    descriptorString = sourceDescriptor.toString();
    
    String classifier1 = sourceDescriptor.getArtifactKey().getClassifier();
    String classifier2 = destinationDescriptor.getArtifactKey().getClassifier();
    if ((!classifier1.equals(classifier2)) || ((!"osgi.bundle".equals(classifier1)) && (!"org.eclipse.update.feature".equals(classifier1)))) {
      return Status.OK_STATUS;
    }
    File firstTempFile = null;
    File secondTempFile = null;
    try
    {
      firstTempFile = getLocalJarFile(source, sourceDescriptor, "sourceartifact");
      secondTempFile = getLocalJarFile(destination, destinationDescriptor, "destinationartifact");
      if (classifier1.equals("osgi.bundle")) {
        return compare(firstTempFile, secondTempFile);
      }
      if (classifier1.equals("org.eclipse.update.feature")) {
        return compareFeatures(firstTempFile, secondTempFile);
      }
    }
    catch (CoreException e)
    {
      IStatus localIStatus;
      return e.getStatus();
    }
    finally
    {
      if (firstTempFile != null) {
        firstTempFile.delete();
      }
      if (secondTempFile != null) {
        secondTempFile.delete();
      }
    }
    if (firstTempFile != null) {
      firstTempFile.delete();
    }
    if (secondTempFile != null) {
      secondTempFile.delete();
    }
    return Status.OK_STATUS;
  }
  
  public IStatus compareFeatures(File sourceFile, File destinationFile)
  {
    FeatureParser parser = new FeatureParser();
    Feature feature1 = parser.parse(sourceFile);
    Feature feature2 = parser.parse(destinationFile);
    
    MultiStatus parent = new MultiStatus("org.eclipse.equinox.p2.repository.tools", 0, NLS.bind(Messages.differentEntry, new String[] { descriptorString, sourceLocation, destinationLocation }), null);
    if (!feature1.getId().equals(feature2.getId())) {
      parent.add(newErrorStatus(NLS.bind(Messages.featureIdsDontMatch, feature1.getId(), feature2.getId())));
    }
    if (!feature1.getVersion().equals(feature2.getVersion())) {
      parent.add(newErrorStatus(NLS.bind(Messages.featureVersionsDontMatch, feature1.getVersion(), feature2.getVersion())));
    }
    Map<FeatureEntryWrapper, FeatureEntry> entryMap = new HashMap();
    FeatureEntry[] entries1 = feature1.getEntries();
    FeatureEntry[] entries2 = feature2.getEntries();
    if (entries1.length != entries2.length) {
      parent.add(newErrorStatus(Messages.featureSize));
    }
    for (int i = 0; i < entries1.length; i++) {
      entryMap.put(new FeatureEntryWrapper(entries1[i]), entries1[i]);
    }
    for (int i = 0; i < entries2.length; i++)
    {
      FeatureEntry firstEntry = (FeatureEntry)entryMap.get(new FeatureEntryWrapper(entries2[i]));
      if (firstEntry == null)
      {
        parent.add(newErrorStatus(NLS.bind(Messages.featureEntry, entries2[i])));
      }
      else
      {
        if (firstEntry.isOptional() != entries2[i].isOptional()) {
          parent.add(newErrorStatus(NLS.bind(Messages.featureEntryOptional, entries2[i])));
        }
        if (firstEntry.isUnpack() != entries2[i].isUnpack()) {
          parent.add(newErrorStatus(NLS.bind(Messages.featureEntryUnpack, entries2[i])));
        }
        if ((firstEntry.isRequires()) && (firstEntry.getMatch() != null) && (!firstEntry.getMatch().equals(entries2[i].getMatch()))) {
          parent.add(newErrorStatus(NLS.bind(Messages.featureEntryMatch, entries2[i])));
        }
        if ((firstEntry.getFilter() != null) && (!firstEntry.getFilter().equals(entries2[i].getFilter()))) {
          parent.add(newErrorStatus(NLS.bind(Messages.featureEntryFilter, entries2[i])));
        }
      }
    }
    return parent.getChildren().length == 0 ? Status.OK_STATUS : parent;
  }
  
  /* Error */
  public IStatus compare(File sourceFile, File destinationFile)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: aconst_null
    //   3: astore 4
    //   5: new 325	java/util/zip/ZipFile
    //   8: dup
    //   9: aload_1
    //   10: invokespecial 631	java/util/zip/ZipFile:<init>	(Ljava/io/File;)V
    //   13: astore_3
    //   14: new 325	java/util/zip/ZipFile
    //   17: dup
    //   18: aload_2
    //   19: invokespecial 631	java/util/zip/ZipFile:<init>	(Ljava/io/File;)V
    //   22: astore 4
    //   24: aload_3
    //   25: invokevirtual 630	java/util/zip/ZipFile:size	()I
    //   28: istore 5
    //   30: aload 4
    //   32: invokevirtual 630	java/util/zip/ZipFile:size	()I
    //   35: istore 6
    //   37: new 328	org/eclipse/core/runtime/MultiStatus
    //   40: dup
    //   41: ldc 11
    //   43: iconst_0
    //   44: getstatic 563	org/eclipse/equinox/p2/internal/repository/comparator/java/Messages:differentEntry	Ljava/lang/String;
    //   47: iconst_3
    //   48: anewarray 312	java/lang/String
    //   51: dup
    //   52: iconst_0
    //   53: aload_0
    //   54: getfield 557	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:descriptorString	Ljava/lang/String;
    //   57: aastore
    //   58: dup
    //   59: iconst_1
    //   60: aload_0
    //   61: getfield 559	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:sourceLocation	Ljava/lang/String;
    //   64: aastore
    //   65: dup
    //   66: iconst_2
    //   67: aload_0
    //   68: getfield 558	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:destinationLocation	Ljava/lang/String;
    //   71: aastore
    //   72: invokestatic 674	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   75: aconst_null
    //   76: invokespecial 639	org/eclipse/core/runtime/MultiStatus:<init>	(Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   79: astore 7
    //   81: iload 5
    //   83: iload 6
    //   85: if_icmpeq +75 -> 160
    //   88: aload 7
    //   90: aload_0
    //   91: getstatic 564	org/eclipse/equinox/p2/internal/repository/comparator/java/Messages:differentNumberOfEntries	Ljava/lang/String;
    //   94: iconst_5
    //   95: anewarray 312	java/lang/String
    //   98: dup
    //   99: iconst_0
    //   100: aload_0
    //   101: getfield 557	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:descriptorString	Ljava/lang/String;
    //   104: aastore
    //   105: dup
    //   106: iconst_1
    //   107: aload_0
    //   108: getfield 559	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:sourceLocation	Ljava/lang/String;
    //   111: aastore
    //   112: dup
    //   113: iconst_2
    //   114: iload 5
    //   116: invokestatic 590	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   119: aastore
    //   120: dup
    //   121: iconst_3
    //   122: aload_0
    //   123: getfield 558	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:destinationLocation	Ljava/lang/String;
    //   126: aastore
    //   127: dup
    //   128: iconst_4
    //   129: iload 6
    //   131: invokestatic 590	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   134: aastore
    //   135: invokestatic 674	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   138: invokespecial 648	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:newErrorStatus	(Ljava/lang/String;)Lorg/eclipse/core/runtime/IStatus;
    //   141: invokevirtual 638	org/eclipse/core/runtime/MultiStatus:add	(Lorg/eclipse/core/runtime/IStatus;)V
    //   144: aload 7
    //   146: astore 22
    //   148: aload_3
    //   149: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   152: aload 4
    //   154: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   157: aload 22
    //   159: areturn
    //   160: aload_3
    //   161: invokevirtual 632	java/util/zip/ZipFile:entries	()Ljava/util/Enumeration;
    //   164: astore 8
    //   166: goto +426 -> 592
    //   169: aload 8
    //   171: invokeinterface 677 1 0
    //   176: checkcast 324	java/util/zip/ZipEntry
    //   179: astore 9
    //   181: aload 9
    //   183: invokevirtual 629	java/util/zip/ZipEntry:getName	()Ljava/lang/String;
    //   186: astore 10
    //   188: aload 4
    //   190: aload 10
    //   192: invokevirtual 634	java/util/zip/ZipFile:getEntry	(Ljava/lang/String;)Ljava/util/zip/ZipEntry;
    //   195: astore 11
    //   197: aconst_null
    //   198: astore 12
    //   200: aload 9
    //   202: invokevirtual 628	java/util/zip/ZipEntry:isDirectory	()Z
    //   205: ifne +306 -> 511
    //   208: aload 11
    //   210: ifnull +301 -> 511
    //   213: aload 10
    //   215: invokevirtual 600	java/lang/String:toLowerCase	()Ljava/lang/String;
    //   218: astore 13
    //   220: aload_0
    //   221: aload 13
    //   223: invokespecial 645	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:isSigningEntry	(Ljava/lang/String;)Z
    //   226: ifeq +6 -> 232
    //   229: goto +363 -> 592
    //   232: aconst_null
    //   233: astore 14
    //   235: aconst_null
    //   236: astore 15
    //   238: new 302	java/io/BufferedInputStream
    //   241: dup
    //   242: aload_3
    //   243: aload 9
    //   245: invokevirtual 633	java/util/zip/ZipFile:getInputStream	(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;
    //   248: invokespecial 581	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   251: astore 14
    //   253: new 302	java/io/BufferedInputStream
    //   256: dup
    //   257: aload 4
    //   259: aload 11
    //   261: invokevirtual 633	java/util/zip/ZipFile:getInputStream	(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;
    //   264: invokespecial 581	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   267: astore 15
    //   269: aload 13
    //   271: ldc 2
    //   273: invokevirtual 604	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   276: ifeq +28 -> 304
    //   279: aload_0
    //   280: aload 10
    //   282: aload 14
    //   284: aload 9
    //   286: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   289: aload 15
    //   291: aload 11
    //   293: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   296: invokespecial 657	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:compareClasses	(Ljava/lang/String;Ljava/io/InputStream;JLjava/io/InputStream;J)Lorg/eclipse/core/runtime/IStatus;
    //   299: astore 12
    //   301: goto +197 -> 498
    //   304: aload 13
    //   306: ldc 4
    //   308: invokevirtual 604	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   311: ifeq +28 -> 339
    //   314: aload_0
    //   315: aload 14
    //   317: aload 9
    //   319: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   322: aload 15
    //   324: aload 11
    //   326: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   329: aload 10
    //   331: invokespecial 659	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:compareNestedJars	(Ljava/io/InputStream;JLjava/io/InputStream;JLjava/lang/String;)Lorg/eclipse/core/runtime/IStatus;
    //   334: astore 12
    //   336: goto +162 -> 498
    //   339: aload 13
    //   341: ldc 6
    //   343: invokevirtual 604	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   346: ifne +13 -> 359
    //   349: aload 13
    //   351: ldc 5
    //   353: invokevirtual 604	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   356: ifeq +18 -> 374
    //   359: aload_0
    //   360: aload 10
    //   362: aload 14
    //   364: aload 15
    //   366: invokespecial 658	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:compareProperties	(Ljava/lang/String;Ljava/io/InputStream;Ljava/io/InputStream;)Lorg/eclipse/core/runtime/IStatus;
    //   369: astore 12
    //   371: goto +127 -> 498
    //   374: aload 10
    //   376: ldc_w 301
    //   379: invokevirtual 605	java/lang/String:equalsIgnoreCase	(Ljava/lang/String;)Z
    //   382: ifeq +16 -> 398
    //   385: aload_0
    //   386: aload 14
    //   388: aload 15
    //   390: invokespecial 653	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:compareManifest	(Ljava/io/InputStream;Ljava/io/InputStream;)Lorg/eclipse/core/runtime/IStatus;
    //   393: astore 12
    //   395: goto +103 -> 498
    //   398: aload 9
    //   400: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   403: lstore 16
    //   405: aload 11
    //   407: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   410: lstore 18
    //   412: lload 16
    //   414: lload 18
    //   416: lcmp
    //   417: ifeq +41 -> 458
    //   420: aload_0
    //   421: getstatic 560	org/eclipse/equinox/p2/internal/repository/comparator/java/Messages:binaryDifferentLength	Ljava/lang/String;
    //   424: iconst_2
    //   425: anewarray 312	java/lang/String
    //   428: dup
    //   429: iconst_0
    //   430: aload 10
    //   432: aastore
    //   433: dup
    //   434: iconst_1
    //   435: lload 16
    //   437: lload 18
    //   439: lsub
    //   440: invokestatic 592	java/lang/Math:abs	(J)J
    //   443: invokestatic 603	java/lang/String:valueOf	(J)Ljava/lang/String;
    //   446: aastore
    //   447: invokestatic 674	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   450: invokespecial 648	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:newErrorStatus	(Ljava/lang/String;)Lorg/eclipse/core/runtime/IStatus;
    //   453: astore 12
    //   455: goto +43 -> 498
    //   458: aload_0
    //   459: aload 10
    //   461: aload 14
    //   463: aload 9
    //   465: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   468: aload 15
    //   470: aload 11
    //   472: invokevirtual 627	java/util/zip/ZipEntry:getSize	()J
    //   475: invokespecial 656	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:compareBytes	(Ljava/lang/String;Ljava/io/InputStream;JLjava/io/InputStream;J)Lorg/eclipse/core/runtime/IStatus;
    //   478: astore 12
    //   480: goto +18 -> 498
    //   483: astore 20
    //   485: aload 14
    //   487: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   490: aload 15
    //   492: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   495: aload 20
    //   497: athrow
    //   498: aload 14
    //   500: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   503: aload 15
    //   505: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   508: goto +46 -> 554
    //   511: aload 9
    //   513: invokevirtual 628	java/util/zip/ZipEntry:isDirectory	()Z
    //   516: ifne +38 -> 554
    //   519: aload_0
    //   520: getstatic 578	org/eclipse/equinox/p2/internal/repository/comparator/java/Messages:missingEntry	Ljava/lang/String;
    //   523: iconst_3
    //   524: anewarray 312	java/lang/String
    //   527: dup
    //   528: iconst_0
    //   529: aload 10
    //   531: aastore
    //   532: dup
    //   533: iconst_1
    //   534: aload_0
    //   535: getfield 557	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:descriptorString	Ljava/lang/String;
    //   538: aastore
    //   539: dup
    //   540: iconst_2
    //   541: aload_0
    //   542: getfield 559	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:sourceLocation	Ljava/lang/String;
    //   545: aastore
    //   546: invokestatic 674	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   549: invokespecial 648	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:newErrorStatus	(Ljava/lang/String;)Lorg/eclipse/core/runtime/IStatus;
    //   552: astore 12
    //   554: aload 12
    //   556: ifnull +36 -> 592
    //   559: aload 12
    //   561: invokeinterface 685 1 0
    //   566: ifne +26 -> 592
    //   569: aload 7
    //   571: aload 12
    //   573: invokevirtual 638	org/eclipse/core/runtime/MultiStatus:add	(Lorg/eclipse/core/runtime/IStatus;)V
    //   576: aload 7
    //   578: astore 22
    //   580: aload_3
    //   581: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   584: aload 4
    //   586: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   589: aload 22
    //   591: areturn
    //   592: aload 8
    //   594: invokeinterface 676 1 0
    //   599: ifne -430 -> 169
    //   602: goto +63 -> 665
    //   605: astore 5
    //   607: aload_0
    //   608: getstatic 574	org/eclipse/equinox/p2/internal/repository/comparator/java/Messages:ioexception	Ljava/lang/String;
    //   611: iconst_2
    //   612: anewarray 312	java/lang/String
    //   615: dup
    //   616: iconst_0
    //   617: aload_1
    //   618: invokevirtual 586	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   621: aastore
    //   622: dup
    //   623: iconst_1
    //   624: aload_2
    //   625: invokevirtual 586	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   628: aastore
    //   629: invokestatic 674	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   632: aload 5
    //   634: invokespecial 654	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:newErrorStatus	(Ljava/lang/String;Ljava/lang/Exception;)Lorg/eclipse/core/runtime/IStatus;
    //   637: astore 22
    //   639: aload_3
    //   640: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   643: aload 4
    //   645: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   648: aload 22
    //   650: areturn
    //   651: astore 21
    //   653: aload_3
    //   654: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   657: aload 4
    //   659: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   662: aload 21
    //   664: athrow
    //   665: aload_3
    //   666: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   669: aload 4
    //   671: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   674: getstatic 556	org/eclipse/core/runtime/Status:OK_STATUS	Lorg/eclipse/core/runtime/IStatus;
    //   677: areturn
    // Line number table:
    //   Java source line #168	-> byte code offset #0
    //   Java source line #169	-> byte code offset #2
    //   Java source line #171	-> byte code offset #5
    //   Java source line #172	-> byte code offset #14
    //   Java source line #173	-> byte code offset #24
    //   Java source line #174	-> byte code offset #30
    //   Java source line #175	-> byte code offset #37
    //   Java source line #177	-> byte code offset #81
    //   Java source line #178	-> byte code offset #88
    //   Java source line #179	-> byte code offset #144
    //   Java source line #231	-> byte code offset #148
    //   Java source line #232	-> byte code offset #152
    //   Java source line #179	-> byte code offset #157
    //   Java source line #181	-> byte code offset #160
    //   Java source line #182	-> byte code offset #169
    //   Java source line #183	-> byte code offset #181
    //   Java source line #184	-> byte code offset #188
    //   Java source line #185	-> byte code offset #197
    //   Java source line #186	-> byte code offset #200
    //   Java source line #187	-> byte code offset #213
    //   Java source line #188	-> byte code offset #220
    //   Java source line #189	-> byte code offset #229
    //   Java source line #192	-> byte code offset #232
    //   Java source line #193	-> byte code offset #235
    //   Java source line #195	-> byte code offset #238
    //   Java source line #196	-> byte code offset #253
    //   Java source line #197	-> byte code offset #269
    //   Java source line #198	-> byte code offset #279
    //   Java source line #199	-> byte code offset #304
    //   Java source line #200	-> byte code offset #314
    //   Java source line #201	-> byte code offset #339
    //   Java source line #202	-> byte code offset #359
    //   Java source line #203	-> byte code offset #374
    //   Java source line #204	-> byte code offset #385
    //   Java source line #206	-> byte code offset #398
    //   Java source line #207	-> byte code offset #405
    //   Java source line #208	-> byte code offset #412
    //   Java source line #209	-> byte code offset #420
    //   Java source line #211	-> byte code offset #458
    //   Java source line #213	-> byte code offset #483
    //   Java source line #214	-> byte code offset #485
    //   Java source line #215	-> byte code offset #490
    //   Java source line #216	-> byte code offset #495
    //   Java source line #214	-> byte code offset #498
    //   Java source line #215	-> byte code offset #503
    //   Java source line #217	-> byte code offset #511
    //   Java source line #219	-> byte code offset #519
    //   Java source line #222	-> byte code offset #554
    //   Java source line #223	-> byte code offset #569
    //   Java source line #224	-> byte code offset #576
    //   Java source line #231	-> byte code offset #580
    //   Java source line #232	-> byte code offset #584
    //   Java source line #224	-> byte code offset #589
    //   Java source line #181	-> byte code offset #592
    //   Java source line #227	-> byte code offset #605
    //   Java source line #229	-> byte code offset #607
    //   Java source line #231	-> byte code offset #639
    //   Java source line #232	-> byte code offset #643
    //   Java source line #229	-> byte code offset #648
    //   Java source line #230	-> byte code offset #651
    //   Java source line #231	-> byte code offset #653
    //   Java source line #232	-> byte code offset #657
    //   Java source line #233	-> byte code offset #662
    //   Java source line #231	-> byte code offset #665
    //   Java source line #232	-> byte code offset #669
    //   Java source line #234	-> byte code offset #674
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	678	0	this	JarComparator
    //   0	678	1	sourceFile	File
    //   0	678	2	destinationFile	File
    //   1	665	3	firstFile	java.util.zip.ZipFile
    //   3	667	4	secondFile	java.util.zip.ZipFile
    //   28	87	5	firstFileSize	int
    //   605	28	5	e	IOException
    //   35	95	6	secondFileSize	int
    //   79	498	7	parent	MultiStatus
    //   164	429	8	enumeration	java.util.Enumeration<? extends java.util.zip.ZipEntry>
    //   179	333	9	entry	java.util.zip.ZipEntry
    //   186	344	10	entryName	String
    //   195	276	11	entry2	java.util.zip.ZipEntry
    //   198	374	12	result	IStatus
    //   218	132	13	lowerCase	String
    //   233	266	14	firstStream	InputStream
    //   236	268	15	secondStream	InputStream
    //   403	33	16	size1	long
    //   410	28	18	size2	long
    //   483	13	20	localObject1	Object
    //   651	12	21	localObject2	Object
    //   146	503	22	localObject3	Object
    // Exception table:
    //   from	to	target	type
    //   238	483	483	finally
    //   5	148	605	java/io/IOException
    //   160	580	605	java/io/IOException
    //   592	602	605	java/io/IOException
    //   5	148	651	finally
    //   160	580	651	finally
    //   592	639	651	finally
  }
  
  private IStatus compareManifest(InputStream firstStream, InputStream secondStream)
    throws IOException
  {
    Manifest manifest = new Manifest(firstStream);
    Manifest manifest2 = new Manifest(secondStream);
    if ((manifest == null) || (manifest2 == null)) {
      return Status.OK_STATUS;
    }
    Attributes attributes = manifest.getMainAttributes();
    Attributes attributes2 = manifest2.getMainAttributes();
    if (attributes.size() != attributes2.size()) {
      return newErrorStatus(NLS.bind(Messages.manifestDifferentSize, String.valueOf(Math.abs(attributes.size() - attributes2.size()))));
    }
    for (Iterator localIterator = attributes.entrySet().iterator(); localIterator.hasNext();)
    {
      Map.Entry<Object, Object> entry = (Map.Entry)localIterator.next();
      Object value2 = attributes2.get(entry.getKey());
      if (value2 == null) {
        return newErrorStatus(NLS.bind(Messages.manifestMissingEntry, entry.getKey()));
      }
      if (!value2.equals(entry.getValue())) {
        return newErrorStatus(NLS.bind(Messages.manifestDifferentValue, entry.getKey()));
      }
    }
    return Status.OK_STATUS;
  }
  
  private IStatus compareClasses(String entryName, InputStream stream1, long size1, InputStream stream2, long size2)
    throws IOException
  {
    Disassembler disassembler = new Disassembler();
    byte[] firstEntryClassFileBytes = Utility.getInputStreamAsByteArray(stream1, (int)size1);
    byte[] secondEntryClassFileBytes = Utility.getInputStreamAsByteArray(stream2, (int)size2);
    
    String contentsFile1 = null;
    try
    {
      contentsFile1 = disassembler.disassemble(firstEntryClassFileBytes, "\n", 9);
    }
    catch (ClassFormatException localClassFormatException1) {}
    String contentsFile2 = null;
    try
    {
      contentsFile2 = disassembler.disassemble(secondEntryClassFileBytes, "\n", 9);
    }
    catch (ClassFormatException localClassFormatException2) {}
    if ((contentsFile1 == null) || (contentsFile2 == null))
    {
      if (contentsFile1 == null)
      {
        if (contentsFile2 != null) {
          return newErrorStatus(NLS.bind(Messages.classesDifferent, entryName));
        }
        if (!Arrays.equals(firstEntryClassFileBytes, secondEntryClassFileBytes)) {
          return newErrorStatus(NLS.bind(Messages.binaryFilesDifferent, entryName));
        }
        return Status.OK_STATUS;
      }
      return newErrorStatus(NLS.bind(Messages.classesDifferent, entryName));
    }
    if (!contentsFile1.equals(contentsFile2)) {
      return newErrorStatus(NLS.bind(Messages.classesDifferent, entryName));
    }
    return Status.OK_STATUS;
  }
  
  private IStatus compareNestedJars(InputStream stream1, long size1, InputStream stream2, long size2, String entry)
    throws IOException
  {
    File firstTempFile = getLocalJarFile(stream1, entry, size1);
    File secondTempFile = getLocalJarFile(stream2, entry, size2);
    try
    {
      return compare(firstTempFile, secondTempFile);
    }
    finally
    {
      if (firstTempFile != null) {
        firstTempFile.delete();
      }
      if (secondTempFile != null) {
        secondTempFile.delete();
      }
    }
  }
  
  private IStatus compareProperties(String entryName, InputStream stream1, InputStream stream2)
  {
    Properties props1 = loadProperties(stream1);
    Properties props2 = loadProperties(stream2);
    if (props1.size() != props2.size()) {
      return newErrorStatus(NLS.bind(Messages.propertiesSizesDifferent, entryName, String.valueOf(Math.abs(props1.size() - props2.size()))));
    }
    props1.keys();
    for (Iterator<Object> iterator = props1.keySet().iterator(); iterator.hasNext();)
    {
      String key = (String)iterator.next();
      if (!props2.containsKey(key)) {
        return newErrorStatus(NLS.bind(Messages.missingProperty, key, entryName));
      }
      String prop1 = props1.getProperty(key);
      String prop2 = props2.getProperty(key);
      if (!prop1.equals(prop2))
      {
        if ((prop1.length() < 15) && (prop2.length() < 15)) {
          return newErrorStatus(NLS.bind(Messages.differentPropertyValueFull, new String[] { entryName, key, prop1, prop2 }));
        }
        String[] diff = extractDifference(prop1, prop2);
        return newErrorStatus(NLS.bind(Messages.differentPropertyValueFull, new String[] { entryName, key, diff[0], diff[1] }));
      }
    }
    return Status.OK_STATUS;
  }
  
  private String[] extractDifference(String s1, String s2)
  {
    for (int i = 0; (i < s1.length()) && (i < s2.length()); i++) {
      if (s1.charAt(i) != s2.charAt(i))
      {
        String result2;
        String result1;
        String result2;
        if (i > 3)
        {
          boolean truncated = i + 7 < s1.length();
          String result1 = "..." + s1.substring(i - 3, truncated ? i + 7 : s1.length()) + (truncated ? "..." : "");
          truncated = i + 7 < s2.length();
          result2 = "..." + s2.substring(i - 3, truncated ? i + 7 : s2.length()) + (truncated ? "..." : "");
        }
        else
        {
          boolean truncated = i + 10 < s1.length();
          result1 = s1.substring(0, truncated ? i + 10 : s1.length()) + (truncated ? "..." : "");
          truncated = i + 10 < s2.length();
          result2 = s2.substring(0, truncated ? i + 10 : s2.length()) + (truncated ? "..." : "");
        }
        return new String[] { result1, result2 };
      }
    }
    return new String[] { s1, s2 };
  }
  
  private IStatus compareBytes(String entryName, InputStream firstStream, long size1, InputStream secondStream, long size2)
    throws IOException
  {
    byte[] firstBytes = Utility.getInputStreamAsByteArray(firstStream, (int)size1);
    byte[] secondBytes = Utility.getInputStreamAsByteArray(secondStream, (int)size2);
    if (!Arrays.equals(firstBytes, secondBytes)) {
      return newErrorStatus(NLS.bind(Messages.binaryFilesDifferent, entryName));
    }
    return Status.OK_STATUS;
  }
  
  private Properties loadProperties(InputStream input)
  {
    Properties result = new Properties();
    try
    {
      result.load(input);
    }
    catch (IOException localIOException) {}
    return result;
  }
  
  private String normalize(String entryName)
  {
    StringBuffer buffer = new StringBuffer();
    char[] chars = entryName.toCharArray();
    int i = 0;
    for (int max = chars.length; i < max; i++)
    {
      char currentChar = chars[i];
      if (!Character.isJavaIdentifierPart(currentChar)) {
        buffer.append('_');
      } else {
        buffer.append(currentChar);
      }
    }
    return String.valueOf(buffer);
  }
  
  private IStatus newErrorStatus(String message, Exception e)
  {
    return new Status(4, "org.eclipse.equinox.p2.repository.tools", message, e);
  }
  
  private IStatus newErrorStatus(String message)
  {
    return newErrorStatus(message, null);
  }
  
  /* Error */
  private File getLocalJarFile(IArtifactRepository repository, IArtifactDescriptor descriptor, String prefix)
    throws CoreException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 4
    //   3: aconst_null
    //   4: astore 5
    //   6: aload_3
    //   7: ldc 4
    //   9: invokestatic 587	java/io/File:createTempFile	(Ljava/lang/String;Ljava/lang/String;)Ljava/io/File;
    //   12: astore 4
    //   14: new 303	java/io/BufferedOutputStream
    //   17: dup
    //   18: new 306	java/io/FileOutputStream
    //   21: dup
    //   22: aload 4
    //   24: invokespecial 588	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   27: invokespecial 584	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   30: astore 5
    //   32: aload_1
    //   33: aload_2
    //   34: aload 5
    //   36: new 329	org/eclipse/core/runtime/NullProgressMonitor
    //   39: dup
    //   40: invokespecial 640	org/eclipse/core/runtime/NullProgressMonitor:<init>	()V
    //   43: invokeinterface 690 4 0
    //   48: astore 6
    //   50: aload 6
    //   52: invokeinterface 685 1 0
    //   57: ifne +13 -> 70
    //   60: new 326	org/eclipse/core/runtime/CoreException
    //   63: dup
    //   64: aload 6
    //   66: invokespecial 636	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   69: athrow
    //   70: aload 5
    //   72: invokevirtual 582	java/io/BufferedOutputStream:flush	()V
    //   75: goto +51 -> 126
    //   78: astore 6
    //   80: new 326	org/eclipse/core/runtime/CoreException
    //   83: dup
    //   84: aload_0
    //   85: ldc_w 299
    //   88: aload 6
    //   90: invokespecial 654	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:newErrorStatus	(Ljava/lang/String;Ljava/lang/Exception;)Lorg/eclipse/core/runtime/IStatus;
    //   93: invokespecial 636	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   96: athrow
    //   97: astore 6
    //   99: new 326	org/eclipse/core/runtime/CoreException
    //   102: dup
    //   103: aload_0
    //   104: ldc_w 300
    //   107: aload 6
    //   109: invokespecial 654	org/eclipse/equinox/p2/internal/repository/comparator/JarComparator:newErrorStatus	(Ljava/lang/String;Ljava/lang/Exception;)Lorg/eclipse/core/runtime/IStatus;
    //   112: invokespecial 636	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   115: athrow
    //   116: astore 7
    //   118: aload 5
    //   120: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   123: aload 7
    //   125: athrow
    //   126: aload 5
    //   128: invokestatic 664	org/eclipse/equinox/p2/internal/repository/comparator/java/Utility:close	(Ljava/lang/Object;)V
    //   131: aload 4
    //   133: areturn
    // Line number table:
    //   Java source line #406	-> byte code offset #0
    //   Java source line #407	-> byte code offset #3
    //   Java source line #409	-> byte code offset #6
    //   Java source line #410	-> byte code offset #14
    //   Java source line #411	-> byte code offset #32
    //   Java source line #412	-> byte code offset #50
    //   Java source line #413	-> byte code offset #60
    //   Java source line #414	-> byte code offset #70
    //   Java source line #
1 2 3 4 5 6 7 8 9 10 11 12

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-2019. Infinite Loop Ltd