org.eclipse.pde.api.tools_1.0.301.v20111129-2053

  // Line number table:
    //   Java source line #1099	-> byte code offset #0
    //   Java source line #1100	-> byte code offset #7
    //   Java source line #1101	-> byte code offset #13
    //   Java source line #1103	-> byte code offset #22
    //   Java source line #1105	-> byte code offset #23
    //   Java source line #1106	-> byte code offset #26
    //   Java source line #1107	-> byte code offset #35
    //   Java source line #1108	-> byte code offset #42
    //   Java source line #1109	-> byte code offset #49
    //   Java source line #1110	-> byte code offset #55
    //   Java source line #1112	-> byte code offset #56
    //   Java source line #1114	-> byte code offset #68
    //   Java source line #1116	-> byte code offset #76
    //   Java source line #1117	-> byte code offset #102
    //   Java source line #1119	-> byte code offset #111
    //   Java source line #1120	-> byte code offset #116
    //   Java source line #1121	-> byte code offset #132
    //   Java source line #1122	-> byte code offset #137
    //   Java source line #1123	-> byte code offset #142
    //   Java source line #1124	-> byte code offset #148
    //   Java source line #1126	-> byte code offset #193
    //   Java source line #1127	-> byte code offset #199
    //   Java source line #1126	-> byte code offset #209
    //   Java source line #1129	-> byte code offset #220
    //   Java source line #1131	-> byte code offset #228
    //   Java source line #1132	-> byte code offset #230
    //   Java source line #1133	-> byte code offset #236
    //   Java source line #1137	-> byte code offset #241
    //   Java source line #1138	-> byte code offset #245
    //   Java source line #1136	-> byte code offset #254
    //   Java source line #1137	-> byte code offset #256
    //   Java source line #1138	-> byte code offset #260
    //   Java source line #1140	-> byte code offset #266
    //   Java source line #1137	-> byte code offset #269
    //   Java source line #1138	-> byte code offset #273
    //   Java source line #1141	-> byte code offset #279
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	280	0	this	BaseApiAnalyzer
    //   0	280	1	context	IBuildContext
    //   0	280	2	component	IApiComponent
    //   0	280	3	monitor	IProgressMonitor
    //   24	96	4	scope	IApiTypeContainer
    //   40	19	5	typenames	String[]
    //   100	121	5	localMonitor	SubMonitor
    //   109	8	6	analyzer	ReferenceAnalyzer
    //   114	50	7	start	long
    //   228	9	7	ce	CoreException
    //   130	85	9	illegal	IApiProblem[]
    //   140	22	10	end	long
    //   194	19	12	i	int
    //   254	13	13	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   111	225	228	org/eclipse/core/runtime/CoreException
    //   111	241	254	finally
  }
  
  String[] getApiUseTypes(IBuildContext context)
  {
    if (context.hasTypes())
    {
      String[] deptypes = (String[])null;
      int size = 0;
      if (context.hasDescriptionDependents())
      {
        deptypes = context.getDescriptionDependentTypes();
        size += deptypes.length;
      }
      String[] structtypes = context.getStructurallyChangedTypes();
      HashSet typenames = new HashSet(size + structtypes.length);
      if (deptypes != null) {
        for (int i = 0; i < deptypes.length; i++) {
          if (deptypes[i] != null) {
            typenames.add(deptypes[i]);
          }
        }
      }
      for (int i = 0; i < structtypes.length; i++) {
        if (structtypes[i] != null) {
          typenames.add(structtypes[i]);
        }
      }
      return (String[])typenames.toArray(new String[typenames.size()]);
    }
    return NO_TYPES;
  }
  
  private void checkCompatibility(String typeName, IApiComponent reference, IApiComponent component, IProgressMonitor monitor)
    throws CoreException
  {
    String id = component.getSymbolicName();
    if (DEBUG) {
      System.out.println("comparing components [" + reference.getSymbolicName() + "] and [" + id + "] for type [" + typeName + "]");
    }
    IApiTypeRoot classFile = null;
    try
    {
      if ("org.eclipse.swt".equals(id)) {
        classFile = component.findTypeRoot(typeName);
      } else {
        classFile = component.findTypeRoot(typeName, id);
      }
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    SubMonitor localmonitor = SubMonitor.convert(monitor, BuilderMessages.BaseApiAnalyzer_checking_compat, 4);
    try
    {
      IDelta delta = null;
      IApiComponent provider = null;
      boolean reexported = false;
      if (classFile == null)
      {
        String packageName = Signatures.getPackageName(typeName);
        
        IApiComponent[] providers = component.getBaseline().resolvePackage(component, packageName);
        int index = 0;
        do
        {
          IApiComponent p = providers[index];
          if (!p.equals(component))
          {
            String id2 = p.getSymbolicName();
            if ("org.eclipse.swt".equals(id2)) {
              classFile = p.findTypeRoot(typeName);
            } else {
              classFile = p.findTypeRoot(typeName, id2);
            }
            if (classFile != null)
            {
              IRequiredComponentDescription[] components = component.getRequiredComponents();
              for (int i = 0; i < components.length; i++)
              {
                IRequiredComponentDescription description = components[i];
                if ((description.getId().equals(p.getSymbolicName())) && (description.isExported()))
                {
                  reexported = true;
                  break;
                }
              }
              provider = p;
            }
          }
          index++;
          if (classFile != null) {
            break;
          }
        } while (index < providers.length);
      }
      else
      {
        provider = component;
      }
      Util.updateMonitor(localmonitor, 1);
      if (classFile == null)
      {
        IApiTypeRoot referenceClassFile = null;
        try
        {
          referenceClassFile = reference.findTypeRoot(typeName);
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e);
        }
        if (referenceClassFile != null) {
          try
          {
            IApiType type = referenceClassFile.getStructure();
            if (type == null) {
              return;
            }
            IApiDescription referenceApiDescription = reference.getApiDescription();
            elementDescription = referenceApiDescription.resolveAnnotations(type.getHandle());
            int restrictions = 0;
            if ((!type.isMemberType()) && (!type.isAnonymous()) && (!type.isLocal()))
            {
              int visibility = 65535;
              if (elementDescription != null)
              {
                restrictions = elementDescription.getRestrictions();
                visibility = elementDescription.getVisibility();
              }
              if ((Util.isDefault(type.getModifiers())) || 
                (Flags.isPrivate(type.getModifiers()))) {
                return;
              }
              if (VisibilityModifiers.isAPI(visibility))
              {
                String deltaComponentID = Util.getDeltaComponentVersionsId(reference);
                delta = new Delta(
                  deltaComponentID, 
                  2, 
                  3, 
                  46, 
                  restrictions, 
                  0, 
                  type.getModifiers(), 
                  0, 
                  typeName, 
                  typeName, 
                  new String[] { typeName, Util.getComponentVersionsId(reference) });
              }
            }
          }
          catch (CoreException e)
          {
            ApiPlugin.log(e);
          }
        }
        Util.updateMonitor(localmonitor, 1);
      }
      else
      {
        fBuildState.cleanup(typeName);
        long time = System.currentTimeMillis();
        try
        {
          IApiComponent exporter = null;
          if (reexported) {
            exporter = component;
          }
          delta = ApiComparator.compare(classFile, reference, provider, exporter, reference.getBaseline(), provider.getBaseline(), 1, localmonitor.newChild(1));
        }
        catch (Exception e)
        {
          ApiPlugin.log(e);
        }
        finally
        {
          if (DEBUG) {
            System.out.println("Time spent for " + typeName + " : " + (System.currentTimeMillis() - time) + "ms");
          }
          fPendingDeltaInfos.clear();
        }
      }
      if (delta == null) {
        return;
      }
      if (delta != ApiComparator.NO_DELTA)
      {
        List allDeltas = Util.collectAllDeltas(delta);
        localmonitor.subTask(BuilderMessages.BaseApiAnalyzer_processing_deltas);
        for (Iterator iterator = allDeltas.iterator(); iterator.hasNext();) {
          processDelta((IDelta)iterator.next(), reference, component);
        }
        Util.updateMonitor(localmonitor, 1);
        if (!fPendingDeltaInfos.isEmpty())
        {
          localmonitor.subTask(BuilderMessages.BaseApiAnalyzer_checking_since_tags);
          for (Iterator iterator = fPendingDeltaInfos.iterator(); iterator.hasNext();) {
            checkSinceTags((Delta)iterator.next(), component);
          }
        }
        Util.updateMonitor(localmonitor, 1);
      }
      else
      {
        Util.updateMonitor(localmonitor, 2);
      }
    }
    finally
    {
      localmonitor.done();
    }
    localmonitor.done();
  }
  
  /* Error */
  private void checkCompatibility(IApiComponent reference, IApiComponent component, IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: invokestatic 1446	java/lang/System:currentTimeMillis	()J
    //   3: lstore 4
    //   5: aload_3
    //   6: getstatic 1394	org/eclipse/pde/api/tools/internal/builder/BuilderMessages:BaseApiAnalyzer_checking_compat	Ljava/lang/String;
    //   9: iconst_3
    //   10: invokestatic 1472	org/eclipse/core/runtime/SubMonitor:convert	(Lorg/eclipse/core/runtime/IProgressMonitor;Ljava/lang/String;I)Lorg/eclipse/core/runtime/SubMonitor;
    //   13: astore 6
    //   15: aconst_null
    //   16: astore 7
    //   18: aload_1
    //   19: ifnonnull +38 -> 57
    //   22: new 814	org/eclipse/pde/api/tools/internal/comparator/Delta
    //   25: dup
    //   26: aconst_null
    //   27: iconst_3
    //   28: iconst_1
    //   29: iconst_3
    //   30: aconst_null
    //   31: aload_2
    //   32: invokeinterface 1702 1 0
    //   37: aload_2
    //   38: invokeinterface 1702 1 0
    //   43: invokespecial 1565	org/eclipse/pde/api/tools/internal/comparator/Delta:<init>	(Ljava/lang/String;IIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    //   46: astore 7
    //   48: aload 6
    //   50: iconst_5
    //   51: invokestatic 1601	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   54: goto +153 -> 207
    //   57: aload_1
    //   58: aload_2
    //   59: iconst_1
    //   60: aload 6
    //   62: iconst_1
    //   63: invokevirtual 1470	org/eclipse/core/runtime/SubMonitor:newChild	(I)Lorg/eclipse/core/runtime/SubMonitor;
    //   66: invokestatic 1584	org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator:compare	(Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;ILorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/pde/api/tools/internal/provisional/comparator/IDelta;
    //   69: astore 7
    //   71: goto +72 -> 143
    //   74: astore 8
    //   76: getstatic 1381	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:DEBUG	Z
    //   79: ifeq +52 -> 131
    //   82: getstatic 1378	java/lang/System:out	Ljava/io/PrintStream;
    //   85: new 757	java/lang/StringBuffer
    //   88: dup
    //   89: ldc_w 705
    //   92: invokespecial 1440	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   95: aload_2
    //   96: invokeinterface 1702 1 0
    //   101: invokevirtual 1445	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   104: ldc_w 666
    //   107: invokevirtual 1445	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   110: invokestatic 1446	java/lang/System:currentTimeMillis	()J
    //   113: lload 4
    //   115: lsub
    //   116: invokevirtual 1443	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   119: ldc_w 728
    //   122: invokevirtual 1445	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   125: invokevirtual 1439	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   128: invokevirtual 1413	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   131: aload_0
    //   132: getfield 1384	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:fPendingDeltaInfos	Ljava/util/List;
    //   135: invokeinterface 1626 1 0
    //   140: aload 8
    //   142: athrow
    //   143: getstatic 1381	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:DEBUG	Z
    //   146: ifeq +52 -> 198
    //   149: getstatic 1378	java/lang/System:out	Ljava/io/PrintStream;
    //   152: new 757	java/lang/StringBuffer
    //   155: dup
    //   156: ldc_w 705
    //   159: invokespecial 1440	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   162: aload_2
    //   163: invokeinterface 1702 1 0
    //   168: invokevirtual 1445	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   171: ldc_w 666
    //   174: invokevirtual 1445	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   177: invokestatic 1446	java/lang/System:currentTimeMillis	()J
    //   180: lload 4
    //   182: lsub
    //   183: invokevirtual 1443	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   186: ldc_w 728
    //   189: invokevirtual 1445	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   192: invokevirtual 1439	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   195: invokevirtual 1413	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   198: aload_0
    //   199: getfield 1384	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:fPendingDeltaInfos	Ljava/util/List;
    //   202: invokeinterface 1626 1 0
    //   207: aload 7
    //   209: ifnonnull +9 -> 218
    //   212: aload 6
    //   214: invokevirtual 1468	org/eclipse/core/runtime/SubMonitor:done	()V
    //   217: return
    //   218: aload 7
    //   220: getstatic 1405	org/eclipse/pde/api/tools/internal/provisional/comparator/ApiComparator:NO_DELTA	Lorg/eclipse/pde/api/tools/internal/provisional/comparator/IDelta;
    //   223: if_acmpeq +140 -> 363
    //   226: aload 7
    //   228: invokestatic 1608	org/eclipse/pde/api/tools/internal/util/Util:collectAllDeltas	(Lorg/eclipse/pde/api/tools/internal/provisional/comparator/IDelta;)Ljava/util/List;
    //   231: astore 8
    //   233: aload 8
    //   235: invokeinterface 1625 1 0
    //   240: ifeq +142 -> 382
    //   243: aload 6
    //   245: getstatic 1398	org/eclipse/pde/api/tools/internal/builder/BuilderMessages:BaseApiAnalyzer_processing_deltas	Ljava/lang/String;
    //   248: invokevirtual 1469	org/eclipse/core/runtime/SubMonitor:subTask	(Ljava/lang/String;)V
    //   251: aload 8
    //   253: invokeinterface 1630 1 0
    //   258: astore 9
    //   260: goto +19 -> 279
    //   263: aload_0
    //   264: aload 9
    //   266: invokeinterface 1624 1 0
    //   271: checkcast 832	org/eclipse/pde/api/tools/internal/provisional/comparator/IDelta
    //   274: aload_1
    //   275: aload_2
    //   276: invokespecial 1528	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:processDelta	(Lorg/eclipse/pde/api/tools/internal/provisional/comparator/IDelta;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;)V
    //   279: aload 9
    //   281: invokeinterface 1623 1 0
    //   286: ifne -23 -> 263
    //   289: aload 6
    //   291: iconst_1
    //   292: invokestatic 1601	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   295: aload 6
    //   297: getstatic 1395	org/eclipse/pde/api/tools/internal/builder/BuilderMessages:BaseApiAnalyzer_checking_since_tags	Ljava/lang/String;
    //   300: invokevirtual 1469	org/eclipse/core/runtime/SubMonitor:subTask	(Ljava/lang/String;)V
    //   303: aload_0
    //   304: getfield 1384	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:fPendingDeltaInfos	Ljava/util/List;
    //   307: invokeinterface 1627 1 0
    //   312: ifne +42 -> 354
    //   315: aload_0
    //   316: getfield 1384	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:fPendingDeltaInfos	Ljava/util/List;
    //   319: invokeinterface 1630 1 0
    //   324: astore 9
    //   326: goto +18 -> 344
    //   329: aload_0
    //   330: aload 9
    //   332: invokeinterface 1624 1 0
    //   337: checkcast 814	org/eclipse/pde/api/tools/internal/comparator/Delta
    //   340: aload_2
    //   341: invokespecial 1520	org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer:checkSinceTags	(Lorg/eclipse/pde/api/tools/internal/comparator/Delta;Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;)V
    //   344: aload 9
    //   346: invokeinterface 1623 1 0
    //   351: ifne -22 -> 329
    //   354: aload 6
    //   356: iconst_1
    //   357: invokestatic 1601	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   360: goto +22 -> 382
    //   363: aload 6
    //   365: iconst_2
    //   366: invokestatic 1601	org/eclipse/pde/api/tools/internal/util/Util:updateMonitor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   369: goto +13 -> 382
    //   372: astore 10
    //   374: aload 6
    //   376: invokevirtual 1468	org/eclipse/core/runtime/SubMonitor:done	()V
    //   379: aload 10
    //   381: athrow
    //   382: aload 6
    //   384: invokevirtual 1468	org/eclipse/core/runtime/SubMonitor:done	()V
    //   387: return
    // Line number table:
    //   Java source line #1342	-> byte code offset #0
    //   Java source line #1343	-> byte code offset #5
    //   Java source line #1345	-> byte code offset #15
    //   Java source line #1346	-> byte code offset #18
    //   Java source line #1348	-> byte code offset #22
    //   Java source line #1349	-> byte code offset #26
    //   Java source line #1350	-> byte code offset #27
    //   Java source line #1351	-> byte code offset #28
    //   Java source line #1352	-> byte code offset #29
    //   Java source line #1353	-> byte code offset #30
    //   Java source line #1354	-> byte code offset #31
    //   Java source line #1355	-> byte code offset #37
    //   Java source line #1348	-> byte code offset #43
    //   Java source line #1347	-> byte code offset #46
    //   Java source line #1356	-> byte code offset #48
    //   Java source line #1359	-> byte code offset #57
    //   Java source line #1360	-> byte code offset #74
    //   Java source line #1361	-> byte code offset #76
    //   Java source line #1362	-> byte code offset #82
    //   Java source line #1364	-> byte code offset #131
    //   Java source line #1365	-> byte code offset #140
    //   Java source line #1361	-> byte code offset #143
    //   Java source line #1362	-> byte code offset #149
    //   Java source line #1364	-> byte code offset #198
    //   Java source line #1367	-> byte code offset #207
    //   Java source line #1392	-> byte code offset #212
    //   Java source line #1368	-> byte code offset #217
    //   Java source line #1370	-> byte code offset #218
    //   Java source line #1371	-> byte code offset #226
    //   Java source line #1372	-> byte code offset #233
    //   Java source line #1373	-> byte code offset #243
    //   Java source line #1374	-> byte code offset #251
    //   Java source line #1375	-> byte code offset #263
    //   Java source line #1374	-> byte code offset #279
    //   Java source line #1377	-> byte code offset #289
    //   Java source line #1378	-> byte code offset #295
    //   Java source line #1379	-> byte code offset #303
    //   Java source line #1380	-> byte code offset #315
    //   Java source line #1381	-> byte code offset #329
    //   Java source line #1380	-> byte code offset #344
    //   Java source line #1384	-> byte code offset #354
    //   Java source line #1388	-> byte code offset #363
    //   Java source line #1391	-> byte code offset #372
    //   Java source line #1392	-> byte code offset #374
    //   Java source line #1393	-> byte code offset #379
    //   Java source line #1392	-> byte code offset #382
    //   Java source line #1394	-> byte code offset #387
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	388	0	this	BaseApiAnalyzer
    //   0	388	1	reference	IApiComponent
    //   0	388	2	component	IApiComponent
    //   0	388	3	monitor	IProgressMonitor
    //   3	178	4	time	long
    //   13	370	6	localmonitor	SubMonitor
    //   16	211	7	delta	IDelta
    //   74	67	8	localObject1	Object
    //   231	21	8	allDeltas	List
    //   258	22	9	iterator	Iterator
    //   324	21	9	iterator	Iterator
    //   372	8	10	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   57	74	74	finally
    //   15	212	372	finally
    //   218	372	372	finally
  }
  
  private void checkSinceTags(Delta delta, IApiComponent component)
    throws CoreException
  {
    if (ignoreSinceTagCheck(null)) {
      return;
    }
    IMember member = Util.getIMember(delta, fJavaProject);
    if ((member == null) || (member.isBinary())) {
      return;
    }
    ICompilationUnit cunit = member.getCompilationUnit();
    if (cunit == null) {
      return;
    }
    try
    {
      if (!cunit.isConsistent()) {
        cunit.makeConsistent(null);
      }
    }
    catch (JavaModelException e)
    {
      e.printStackTrace();
    }
    IApiProblem problem = null;
    ISourceRange nameRange = null;
    try
    {
      nameRange = member.getNameRange();
    }
    catch (JavaModelException e)
    {
      ApiPlugin.log(e);
      return;
    }
    if (nameRange == null) {
      return;
    }
    try
    {
      int offset = nameRange.getOffset();
      CompilationUnit comp = createAST(cunit, offset);
      if (comp == null) {
        return;
      }
      SinceTagChecker visitor = new SinceTagChecker(offset);
      comp.accept(visitor);
      
      String componentVersionId = delta.getComponentVersionId();
      String componentVersionString = null;
      if (componentVersionId == null) {
        componentVersionString = component.getVersion();
      } else {
        componentVersionString = extractVersion(componentVersionId);
      }
      try
      {
        if ((visitor.hasNoComment()) || (visitor.isMissing()))
        {
          if (ignoreSinceTagCheck("missing_since_tag"))
          {
            if (DEBUG) {
              System.out.println("Ignoring missing since tag problem");
            }
            return;
          }
          StringBuffer buffer = new StringBuffer();
          Version componentVersion = new Version(componentVersionString);
          buffer.append(componentVersion.getMajor()).append('.').append(componentVersion.getMinor());
          problem = createSinceTagProblem(3, new String[] { Util.getDeltaArgumentString(delta) }, delta, member, String.valueOf(buffer));
        }
        else if (visitor.hasJavadocComment())
        {
          String sinceVersion = visitor.getSinceVersion();
          if (sinceVersion != null)
          {
            SinceTagVersion tagVersion = new SinceTagVersion(sinceVersion);
            String postfixString = tagVersion.postfixString();
            if ((tagVersion.getVersion() == null) || (Util.getFragmentNumber(tagVersion.getVersionString()) > 2))
            {
              if (ignoreSinceTagCheck("malformed_since_tag"))
              {
                if (DEBUG) {
                  System.out.println("Ignoring malformed since tag problem");
                }
                return;
              }
              StringBuffer buffer = new StringBuffer();
              if (tagVersion.prefixString() != null) {
                buffer.append(tagVersion.prefixString());
              }
              Version componentVersion = new Version(componentVersionString);
              buffer.append(componentVersion.getMajor()).append('.').append(componentVersion.getMinor());
              if (postfixString != null) {
                buffer.append(postfixString);
              }
              problem = createSinceTagProblem(2, new String[] { sinceVersion, Util.getDeltaArgumentString(delta) }, delta, member, String.valueOf(buffer));
            }
            else
            {
              if (ignoreSinceTagCheck("invalid_since_tag_version"))
              {
                if (DEBUG) {
                  System.out.println("Ignoring invalid tag version problem");
                }
                return;
              }
              StringBuffer accurateVersionBuffer = new StringBuffer();
              Version componentVersion = new Version(componentVersionString);
              accurateVersionBuffer.append(componentVersion.getMajor()).append('.').append(componentVersion.getMinor());
              String accurateVersion = String.valueOf(accurateVersionBuffer);
              if (Util.isDifferentVersion(sinceVersion, accurateVersion))
              {
                StringBuffer buffer = new StringBuffer();
                if (tagVersion.prefixString() != null) {
                  buffer.append(tagVersion.prefixString());
                }
                Version version = new Version(accurateVersion);
                buffer.append(version.getMajor()).append('.').append(version.getMinor());
                if (postfixString != null) {
                  buffer.append(postfixString);
                }
                String accurateSinceTagValue = String.valueOf(buffer);
                problem = createSinceTagProblem(1, new String[] { sinceVersion, accurateSinceTagValue, Util.getDeltaArgumentString(delta) }, delta, member, accurateSinceTagValue);
              }
            }
          }
        }
      }
      catch (IllegalArgumentException e)
      {
        ApiPlugin.log(e);
      }
      if (problem == null) {
        return;
      }
    }
    catch (RuntimeException e)
    {
      ApiPlugin.log(e);
    }
    addProblem(problem);
  }
  
  private String extractVersion(String componentVersionId)
  {
    int indexOfOpen = componentVersionId.lastIndexOf('(');
    return componentVersionId.substring(indexOfOpen + 1, componentVersionId.length() - 1);
  }
  
  private IApiProblem createSinceTagProblem(int kind, String[] messageargs, Delta info, IMember member, String version)
  {
    try
    {
      IType declaringType = null;
      if (member.getElementType() == 7) {
        declaringType = (IType)member;
      } else {
        declaringType = member.getDeclaringType();
      }
      IResource resource = Util.getResource(fJavaProject.getProject(), declaringType);
      if (resource == null) {
        return null;
      }
      int lineNumber = 1;
      int charStart = 0;
      int charEnd = 1;
      String qtn = null;
      if ((member instanceof IType)) {
        qtn = ((IType)member).getFullyQualifiedName();
      } else {
        qtn = declaringType.getFullyQualifiedName();
      }
      String[] messageArguments = (String[])null;
      if (!Util.isManifest(resource.getProjectRelativePath()))
      {
        messageArguments = messageargs;
        ICompilationUnit unit = member.getCompilationUnit();
        ISourceRange range = member.getNameRange();
        charStart = range.getOffset();
        charEnd = charStart + range.getLength();
        try
        {
          IDocument document = Util.getDocument(unit);
          lineNumber = document.getLineOfOffset(charStart);
        }
        catch (BadLocationException e)
        {
          ApiPlugin.log(e);
        }
      }
      else if (!(member instanceof IType))
      {
        int length = messageargs.length;
        messageArguments = new String[length];
        System.arraycopy(messageargs, 0, messageArguments, 0, length);
        StringBuffer buffer = new StringBuffer();
        buffer.append(qtn).append('.').append(messageargs[(length - 1)]);
        messageArguments[(length - 1)] = String.valueOf(buffer);
      }
      else
      {
        messageArguments = messageargs;
      }
      return ApiProblemFactory.newApiSinceTagProblem(resource.getProjectRelativePath().toPortableString(), 
        qtn, 
        messageArguments, 
        new String[] { "version", "apiMarkerID", "org.eclipse.jdt.internal.core.JavaModelManager.handleId" }, 
        new Object[] { version, new Integer(5), member.getHandleIdentifier() }, 
        lineNumber, 
        charStart, 
        charEnd, 
        info.getElementType(), 
        kind);
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return null;
  }
  
  private IApiProblem createCompatibilityProblem(IDelta delta, IApiComponent reference, IApiComponent component)
  {
    try
    {
      Version referenceVersion = new Version(reference.getVersion());
      Version componentVersion = new Version(component.getVersion());
      if ((referenceVersion.getMajor() < componentVersion.getMajor()) && 
        (!reportApiBreakageWhenMajorVersionIncremented()))
      {
        fBuildState.addBreakingChange(delta);
        return null;
      }
      IResource resource = null;
      IType type = null;
      
      int lineNumber = 0;
      int charStart = -1;
      int charEnd = 1;
      IMember member = null;
      if (fJavaProject != null)
      {
        try
        {
          type = fJavaProject.findType(delta.getTypeName().replace('$', '.'));
        }
        catch (JavaModelException e)
        {
          ApiPlugin.log(e);
        }
        IProject project = fJavaProject.getProject();
        resource = Util.getResource(project, type);
        if (resource == null) {
          return null;
        }
        if (!Util.isManifest(resource.getProjectRelativePath())) {
          member = Util.getIMember(delta, fJavaProject);
        }
        if ((member != null) && (!member.isBinary()) && (member.exists()))
        {
          ISourceRange range = member.getNameRange();
          charStart = range.getOffset();
          charEnd = charStart + range.getLength();
          try
          {
            IDocument document = Util.getDocument(member.getCompilationUnit());
            lineNumber = document.getLineOfOffset(charStart);
          }
          catch (BadLocationException localBadLocationException) {}
        }
      }
      String path = null;
      if (resource != null) {
        path = resource.getProjectRelativePath().toPortableString();
      }
      return ApiProblemFactory.newApiProblem(path, 
        delta.getTypeName(), 
        delta.getArguments(), 
        new String[] {
        "org.eclipse.jdt.internal.core.JavaModelManager.handleId", 
        "apiMarkerID" }, 
        
        new Object[] {
        member == null ? null : member.getHandleIdentifier(), 
        new Integer(2) }, 
        
        lineNumber, 
        charStart, 
        charEnd, 
        268435456, 
        delta.getElementType(), 
        delta.getKind(), 
        delta.getFlags());
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return null;
  }
  
  private void createApiComponentResolutionProblem(IApiComponent component, String message)
    throws CoreException
  {
    IApiProblem problem = ApiProblemFactory.newApiComponentResolutionProblem(
      Path.EMPTY.toString(), 
      new String[] { component.getSymbolicName(), message }, 
      new String[] { "apiMarkerID" }, 
      new Object[] { new Integer(8) }, 
      7, 
      1);
    addProblem(problem);
  }
  
  private void processDelta(IDelta delta, IApiComponent reference, IApiComponent component)
  {
    int flags = delta.getFlags();
    int kind = delta.getKind();
    int modifiers = delta.getNewModifiers();
    if (DeltaProcessor.isCompatible(delta))
    {
      if ((!RestrictionModifiers.isReferenceRestriction(delta.getCurrentRestrictions())) && 
        (Util.isVisible(modifiers)))
      {
        if (Flags.isProtected(modifiers))
        {
          String typeName = delta.getTypeName();
          if (typeName != null)
          {
            IApiTypeRoot typeRoot = null;
            IApiType type = null;
            try
            {
              String id = component.getSymbolicName();
              if ("org.eclipse.swt".equals(id)) {
                typeRoot = component.findTypeRoot(typeName);
              } else {
                typeRoot = component.findTypeRoot(typeName, id);
              }
              if (typeRoot == null)
              {
                String packageName = Signatures.getPackageName(typeName);
                
                IApiComponent[] providers = component.getBaseline().resolvePackage(component, packageName);
                int index = 0;
                while ((typeRoot == null) && (index < providers.length))
                {
                  IApiComponent p = providers[index];
                  if (!p.equals(component))
                  {
                    String id2 = p.getSymbolicName();
                    if ("org.eclipse.swt".equals(id2)) {
                      typeRoot = p.findTypeRoot(typeName);
                    } else {
                      typeRoot = p.findTypeRoot(typeName, id2);
                    }
                  }
                  index++;
                }
              }
              if (typeRoot == null) {
                return;
              }
              type = typeRoot.getStructure();
            }
            catch (CoreException localCoreException) {}
            if ((type == null) || (Flags.isFinal(type.getModifiers()))) {
              return;
            }
          }
        }
        switch (kind)
        {
        case 1: 
          switch (flags)
          {
          case 8: 
          case 12: 
          case 16: 
          case 25: 
          case 27: 
          case 28: 
          case 46: 
          case 48: 
            if (DEBUG)
            {
              String deltaDetails = "Delta : " + Util.getDetail(delta);
              System.out.println(deltaDetails + " is compatible");
            }
            fBuildState.addCompatibleChange(delta);
            fPendingDeltaInfos.add(delta);
          }
          break;
        case 2: 
          if (flags != 22) {
            break;
          }
          if (DEBUG)
          {
            String deltaDetails = "Delta : " + Util.getDetail(delta);
            System.out.println(deltaDetails + " is compatible");
          }
          fBuildState.addCompatibleChange(delta);
          fPendingDeltaInfos.add(delta);
        }
      }
    }
    else
    {
      switch (kind)
      {
      case 1: 
        switch (flags)
        {
        case 8: 
        case 12: 
        case 16: 
        case 25: 
        case 27: 
        case 28: 
        case 48: 
          if (Util.isVisible(modifiers))
          {
            if (DEBUG)
            {
              String deltaDetails = "Delta : " + Util.getDetail(delta);
              System.err.println(deltaDetails + " is not compatible");
            }
            fPendingDeltaInfos.add(delta);
          }
          break;
        }
        break;
      }
      IApiProblem problem = createCompatibilityProblem(delta, reference, component);
      if (addProblem(problem)) {
        fBuildState.addBreakingChange(delta);
      }
    }
  }
  
  private void checkApiComponentVersion(IApiComponent reference, IApiComponent component)
    throws CoreException
  {
    if ((ignoreComponentVersionCheck()) || (reference == null) || (component == null))
    {
      if (DEBUG) {
        System.out.println("Ignoring component version check");
      }
      return;
    }
    IApiProblem problem = null;
    String refversionval = reference.getVersion();
    String compversionval = component.getVersion();
    Version refversion = new Version(refversionval);
    Version compversion = new Version(compversionval);
    Version newversion = null;
    if (DEBUG)
    {
      System.out.println("reference version of " + reference.getSymbolicName() + " : " + refversion);
      System.out.println("component version of " + component.getSymbolicName() + " : " + compversion);
    }
    IDelta[] breakingChanges = fBuildState.getBreakingChanges();
    if (breakingChanges.length != 0)
    {
      if (compversion.getMajor() <= refversion.getMajor())
      {
        newversion = new Version(compversion.getMajor() + 1, 0, 0, compversion.getQualifier() != null ? "qualifier" : null);
        problem = createVersionProblem(
          1, 
          new String[] {
          compversionval, 
          refversionval }, 
          
          String.valueOf(newversion), 
          collectDetails(breakingChanges));
      }
    }
    else
    {
      IDelta[] compatibleChanges = fBuildState.getCompatibleChanges();
      if (compatibleChanges.length != 0)
      {
        if (compversion.getMajor() != refversion.getMajor())
        {
          if (!ignoreMajorVersionCheckWithoutBreakingChange())
          {
            newversion = new Version(refversion.getMajor(), refversion.getMinor() + 1, 0, compversion.getQualifier() != null ? "qualifier" : null);
            problem = createVersionProblem(
              3, 
              new String[] {
              compversionval, 
              refversionval }, 
              
              String.valueOf(newversion), 
              collectDetails(compatibleChanges));
          }
        }
        else if (compversion.getMinor() <= refversion.getMinor())
        {
          newversion = new Version(compversion.getMajor(), compversion.getMinor() + 1, 0, compversion.getQualifier() != null ? "qualifier" : null);
          problem = createVersionProblem(
            2, 
            new String[] {
            compversionval, 
            refversionval }, 
            
            String.valueOf(newversion), 
            collectDetails(compatibleChanges));
        }
      }
      else if (compversion.getMajor() != refversion.getMajor())
      {
        if (!ignoreMajorVersionCheckWithoutBreakingChange())
        {
          newversion = new Version(refversion.getMajor(), refversion.getMinor(), refversion.getMicro(), refversion.getQualifier() != null ? "qualifier" : null);
          problem = createVersionProblem(
            3, 
            new String[] {
            compversionval, 
            refversionval }, 
            
            String.valueOf(newversion), 
            "");
        }
      }
      else if (compversion.getMinor() > refversion.getMinor()) {
        if (!ignoreMinorVersionCheckWithoutApiChange())
        {
          newversion = new Version(refversion.getMajor(), refversion.getMinor(), refversion.getMicro(), refversion.getQualifier() != null ? "qualifier" : null);
          problem = createVersionProblem(
            4, 
            new String[] {
            compversionval, 
            refversionval }, 
            
            String.valueOf(newversion), 
            "");
        }
      }
      ReexportedBundleVersionInfo info = null;
      if (problem != null)
      {
        switch (problem.getKind())
        {
        case 3: 
          info = checkBundleVersionsOfReexportedBundles(reference, component);
          if (info == null) {
            break;
          }
          switch (kind)
          {
          case 5: 
            problem = null;
            break;
          case 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

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