org.eclipse.osgi_3.8.2.v20130124-134944

h, String message)
  {
    if (isDebuggingEnabled(optionPath))
    {
      FrameworkDebugTraceEntry record = new FrameworkDebugTraceEntry(bundleSymbolicName, optionPath, message, traceClass);
      writeRecord(record);
    }
  }
  
  public void trace(String optionPath, String message, Throwable error)
  {
    if (isDebuggingEnabled(optionPath))
    {
      FrameworkDebugTraceEntry record = new FrameworkDebugTraceEntry(bundleSymbolicName, optionPath, message, error, traceClass);
      writeRecord(record);
    }
  }
  
  public void traceEntry(String optionPath)
  {
    if (isDebuggingEnabled(optionPath))
    {
      FrameworkDebugTraceEntry record = new FrameworkDebugTraceEntry(bundleSymbolicName, optionPath, null, traceClass);
      setMessage(record, "Entering method {0}with no parameters");
      writeRecord(record);
    }
  }
  
  public void traceEntry(String optionPath, Object methodArgument)
  {
    if (isDebuggingEnabled(optionPath)) {
      traceEntry(optionPath, new Object[] { methodArgument });
    }
  }
  
  public void traceEntry(String optionPath, Object[] methodArguments)
  {
    if (isDebuggingEnabled(optionPath))
    {
      StringBuffer messageBuffer = new StringBuffer("Entering method {0}with parameters: (");
      if (methodArguments != null)
      {
        int i = 0;
        while (i < methodArguments.length)
        {
          if (methodArguments[i] != null) {
            messageBuffer.append(methodArguments[i].toString());
          } else {
            messageBuffer.append("<null>");
          }
          i++;
          if (i < methodArguments.length) {
            messageBuffer.append(" ");
          }
        }
        messageBuffer.append(")");
      }
      FrameworkDebugTraceEntry record = new FrameworkDebugTraceEntry(bundleSymbolicName, optionPath, null, traceClass);
      setMessage(record, messageBuffer.toString());
      writeRecord(record);
    }
  }
  
  public void traceExit(String optionPath)
  {
    if (isDebuggingEnabled(optionPath))
    {
      FrameworkDebugTraceEntry record = new FrameworkDebugTraceEntry(bundleSymbolicName, optionPath, null, traceClass);
      setMessage(record, "Exiting method {0}with a void return");
      writeRecord(record);
    }
  }
  
  public void traceExit(String optionPath, Object result)
  {
    if (isDebuggingEnabled(optionPath))
    {
      StringBuffer messageBuffer = new StringBuffer("Exiting method {0}with result: ");
      if (result == null) {
        messageBuffer.append("<null>");
      } else {
        messageBuffer.append(result.toString());
      }
      FrameworkDebugTraceEntry record = new FrameworkDebugTraceEntry(bundleSymbolicName, optionPath, null, traceClass);
      setMessage(record, messageBuffer.toString());
      writeRecord(record);
    }
  }
  
  public void traceDumpStack(String optionPath)
  {
    if (isDebuggingEnabled(optionPath))
    {
      StringBuffer messageBuffer = new StringBuffer("Thread Stack dump: ");
      StackTraceElement[] elements = new Exception().getStackTrace();
      
      int firstIndex = traceClass == null ? 1 : 2;
      int endIndex = elements.length - firstIndex;
      StackTraceElement[] newElements = new StackTraceElement[endIndex];
      int i = 0;
      while (i < endIndex)
      {
        newElements[i] = elements[firstIndex];
        i++;
        firstIndex++;
      }
      messageBuffer.append(convertStackTraceElementsToString(newElements));
      FrameworkDebugTraceEntry record = new FrameworkDebugTraceEntry(bundleSymbolicName, optionPath, messageBuffer.toString(), traceClass);
      writeRecord(record);
    }
  }
  
  private final void setMessage(FrameworkDebugTraceEntry record, String originalMessage)
  {
    String argument = null;
    if (!debugOptions.isVerbose())
    {
      StringBuffer classMethodName = new StringBuffer(record.getClassName());
      classMethodName.append("#");
      classMethodName.append(record.getMethodName());
      classMethodName.append(" ");
      argument = classMethodName.toString();
    }
    else
    {
      argument = "";
    }
    String newMessage = MessageFormat.format(originalMessage, new Object[] { argument });
    record.setMessage(newMessage);
  }
  
  private final String convertStackTraceElementsToString(StackTraceElement[] elements)
  {
    StringBuffer buffer = new StringBuffer();
    if (elements != null)
    {
      buffer.append("java.lang.Throwable: ");
      buffer.append(LINE_SEPARATOR);
      int i = 0;
      while (i < elements.length)
      {
        if (elements[i] != null)
        {
          buffer.append("\tat ");
          buffer.append(elements[i].toString());
          buffer.append(LINE_SEPARATOR);
        }
        i++;
      }
    }
    return buffer.toString();
  }
  
  /* Error */
  private void writeRecord(FrameworkDebugTraceEntry entry)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnull +137 -> 138
    //   4: getstatic 441	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeLock	Ljava/lang/Object;
    //   7: dup
    //   8: astore_2
    //   9: monitorenter
    //   10: aload_0
    //   11: getfield 446	org/eclipse/osgi/framework/debug/EclipseDebugTrace:debugOptions	Lorg/eclipse/osgi/framework/debug/FrameworkDebugOptions;
    //   14: invokevirtual 517	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:getFile	()Ljava/io/File;
    //   17: astore_3
    //   18: aconst_null
    //   19: astore 4
    //   21: aload_0
    //   22: aload_3
    //   23: aload_1
    //   24: invokevirtual 522	org/eclipse/osgi/framework/debug/FrameworkDebugTraceEntry:getTimestamp	()J
    //   27: invokespecial 499	org/eclipse/osgi/framework/debug/EclipseDebugTrace:checkTraceFileSize	(Ljava/io/File;J)Z
    //   30: pop
    //   31: aload_0
    //   32: aload_3
    //   33: invokespecial 505	org/eclipse/osgi/framework/debug/EclipseDebugTrace:openWriter	(Ljava/io/File;)Ljava/io/Writer;
    //   36: astore 4
    //   38: getstatic 440	org/eclipse/osgi/framework/debug/EclipseDebugTrace:newSession	Z
    //   41: ifeq +17 -> 58
    //   44: aload_0
    //   45: aload 4
    //   47: aload_1
    //   48: invokevirtual 522	org/eclipse/osgi/framework/debug/FrameworkDebugTraceEntry:getTimestamp	()J
    //   51: invokespecial 501	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeSession	(Ljava/io/Writer;J)V
    //   54: iconst_0
    //   55: putstatic 440	org/eclipse/osgi/framework/debug/EclipseDebugTrace:newSession	Z
    //   58: aload_0
    //   59: aload 4
    //   61: aload_1
    //   62: invokespecial 513	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeMessage	(Ljava/io/Writer;Lorg/eclipse/osgi/framework/debug/FrameworkDebugTraceEntry;)V
    //   65: aload 4
    //   67: invokevirtual 465	java/io/Writer:flush	()V
    //   70: goto +50 -> 120
    //   73: astore 5
    //   75: getstatic 435	java/lang/System:err	Ljava/io/PrintStream;
    //   78: ldc_w 242
    //   81: invokevirtual 463	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   84: aload 5
    //   86: getstatic 435	java/lang/System:err	Ljava/io/PrintStream;
    //   89: invokevirtual 469	java/lang/Exception:printStackTrace	(Ljava/io/PrintStream;)V
    //   92: aload_3
    //   93: ifnull +37 -> 130
    //   96: aload_0
    //   97: aload 4
    //   99: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   102: goto +28 -> 130
    //   105: astore 6
    //   107: aload_3
    //   108: ifnull +9 -> 117
    //   111: aload_0
    //   112: aload 4
    //   114: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   117: aload 6
    //   119: athrow
    //   120: aload_3
    //   121: ifnull +9 -> 130
    //   124: aload_0
    //   125: aload 4
    //   127: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   130: aload_2
    //   131: monitorexit
    //   132: goto +6 -> 138
    //   135: aload_2
    //   136: monitorexit
    //   137: athrow
    //   138: return
    // Line number table:
    //   Java source line #337	-> byte code offset #0
    //   Java source line #338	-> byte code offset #4
    //   Java source line #339	-> byte code offset #10
    //   Java source line #340	-> byte code offset #18
    //   Java source line #343	-> byte code offset #21
    //   Java source line #345	-> byte code offset #31
    //   Java source line #346	-> byte code offset #38
    //   Java source line #347	-> byte code offset #44
    //   Java source line #348	-> byte code offset #54
    //   Java source line #350	-> byte code offset #58
    //   Java source line #352	-> byte code offset #65
    //   Java source line #353	-> byte code offset #70
    //   Java source line #355	-> byte code offset #75
    //   Java source line #356	-> byte code offset #84
    //   Java source line #359	-> byte code offset #92
    //   Java source line #360	-> byte code offset #96
    //   Java source line #357	-> byte code offset #105
    //   Java source line #359	-> byte code offset #107
    //   Java source line #360	-> byte code offset #111
    //   Java source line #362	-> byte code offset #117
    //   Java source line #359	-> byte code offset #120
    //   Java source line #360	-> byte code offset #124
    //   Java source line #338	-> byte code offset #130
    //   Java source line #365	-> byte code offset #138
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	139	0	this	EclipseDebugTrace
    //   0	139	1	entry	FrameworkDebugTraceEntry
    //   8	128	2	Ljava/lang/Object;	Object
    //   17	104	3	tracingFile	File
    //   19	107	4	traceWriter	Writer
    //   73	12	5	ex	Exception
    //   105	13	6	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   21	70	73	java/lang/Exception
    //   21	92	105	finally
    //   10	132	135	finally
    //   135	137	135	finally
  }
  
  private void readLogProperties()
  {
    String newMaxTraceFileSize = secureAction.getProperty("eclipse.trace.size.max");
    if (newMaxTraceFileSize != null)
    {
      maxTraceFileSize = Integer.parseInt(newMaxTraceFileSize);
      if ((maxTraceFileSize != 0) && (maxTraceFileSize < 10)) {
        maxTraceFileSize = 10;
      }
    }
    String newMaxLogFiles = secureAction.getProperty("eclipse.trace.backup.max");
    if (newMaxLogFiles != null)
    {
      maxTraceFiles = Integer.parseInt(newMaxLogFiles);
      if (maxTraceFiles < 1) {
        maxTraceFiles = 10;
      }
    }
  }
  
  /* Error */
  private boolean checkTraceFileSize(File traceFile, long timestamp)
  {
    // Byte code:
    //   0: iconst_1
    //   1: istore 4
    //   3: aload_0
    //   4: getfield 438	org/eclipse/osgi/framework/debug/EclipseDebugTrace:maxTraceFileSize	I
    //   7: ifle +468 -> 475
    //   10: aload_1
    //   11: ifnull +464 -> 475
    //   14: aload_1
    //   15: invokevirtual 453	java/io/File:exists	()Z
    //   18: ifeq +457 -> 475
    //   21: aload_1
    //   22: invokevirtual 451	java/io/File:length	()J
    //   25: bipush 10
    //   27: lshr
    //   28: aload_0
    //   29: getfield 438	org/eclipse/osgi/framework/debug/EclipseDebugTrace:maxTraceFileSize	I
    //   32: i2l
    //   33: lcmp
    //   34: ifle +441 -> 475
    //   37: aload_1
    //   38: invokevirtual 455	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   41: astore 5
    //   43: ldc_w 238
    //   46: astore 6
    //   48: aload 5
    //   50: invokevirtual 476	java/lang/String:toLowerCase	()Ljava/lang/String;
    //   53: ldc 8
    //   55: invokevirtual 479	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   58: ifeq +55 -> 113
    //   61: new 267	java/lang/StringBuffer
    //   64: dup
    //   65: aload 5
    //   67: iconst_0
    //   68: aload 5
    //   70: invokevirtual 475	java/lang/String:length	()I
    //   73: ldc 8
    //   75: invokevirtual 475	java/lang/String:length	()I
    //   78: isub
    //   79: invokevirtual 477	java/lang/String:substring	(II)Ljava/lang/String;
    //   82: invokestatic 480	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   85: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   88: ldc 7
    //   90: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   93: aload_0
    //   94: getfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   97: invokevirtual 485	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   100: ldc 8
    //   102: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   105: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   108: astore 6
    //   110: goto +32 -> 142
    //   113: new 267	java/lang/StringBuffer
    //   116: dup
    //   117: aload 5
    //   119: invokestatic 480	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   122: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   125: ldc 7
    //   127: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   130: aload_0
    //   131: getfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   134: invokevirtual 485	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   137: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   140: astore 6
    //   142: new 255	java/io/File
    //   145: dup
    //   146: aload 6
    //   148: invokespecial 457	java/io/File:<init>	(Ljava/lang/String;)V
    //   151: astore 7
    //   153: aload 7
    //   155: invokevirtual 453	java/io/File:exists	()Z
    //   158: ifeq +119 -> 277
    //   161: aload 7
    //   163: invokevirtual 452	java/io/File:delete	()Z
    //   166: ifne +111 -> 277
    //   169: getstatic 435	java/lang/System:err	Ljava/io/PrintStream;
    //   172: new 267	java/lang/StringBuffer
    //   175: dup
    //   176: ldc_w 244
    //   179: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   182: aload 7
    //   184: invokevirtual 456	java/io/File:getName	()Ljava/lang/String;
    //   187: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   190: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   193: invokevirtual 463	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   196: aload 7
    //   198: new 255	java/io/File
    //   201: dup
    //   202: new 267	java/lang/StringBuffer
    //   205: dup
    //   206: aload 7
    //   208: invokevirtual 455	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   211: invokestatic 480	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   214: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   217: invokestatic 490	java/lang/System:currentTimeMillis	()J
    //   220: invokevirtual 486	java/lang/StringBuffer:append	(J)Ljava/lang/StringBuffer;
    //   223: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   226: invokespecial 457	java/io/File:<init>	(Ljava/lang/String;)V
    //   229: invokevirtual 454	java/io/File:renameTo	(Ljava/io/File;)Z
    //   232: ifeq +33 -> 265
    //   235: getstatic 435	java/lang/System:err	Ljava/io/PrintStream;
    //   238: new 267	java/lang/StringBuffer
    //   241: dup
    //   242: ldc_w 246
    //   245: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   248: aload 7
    //   250: invokevirtual 456	java/io/File:getName	()Ljava/lang/String;
    //   253: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   256: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   259: invokevirtual 463	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   262: goto +15 -> 277
    //   265: getstatic 435	java/lang/System:err	Ljava/io/PrintStream;
    //   268: ldc_w 243
    //   271: invokevirtual 463	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   274: iconst_0
    //   275: istore 4
    //   277: aload_1
    //   278: aload 7
    //   280: invokevirtual 454	java/io/File:renameTo	(Ljava/io/File;)Z
    //   283: istore 8
    //   285: iload 8
    //   287: ifne +15 -> 302
    //   290: getstatic 435	java/lang/System:err	Ljava/io/PrintStream;
    //   293: ldc_w 245
    //   296: invokevirtual 463	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   299: iconst_0
    //   300: istore 4
    //   302: aconst_null
    //   303: astore 9
    //   305: aload_0
    //   306: aload_1
    //   307: invokespecial 505	org/eclipse/osgi/framework/debug/EclipseDebugTrace:openWriter	(Ljava/io/File;)Ljava/io/Writer;
    //   310: astore 9
    //   312: aload_0
    //   313: aload 9
    //   315: new 267	java/lang/StringBuffer
    //   318: dup
    //   319: ldc_w 248
    //   322: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   325: aload 7
    //   327: invokevirtual 455	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   330: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   333: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   336: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   339: aload_0
    //   340: aload 9
    //   342: ldc_w 252
    //   345: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   348: aload_0
    //   349: aload 9
    //   351: new 267	java/lang/StringBuffer
    //   354: dup
    //   355: ldc 19
    //   357: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   360: aload_0
    //   361: getfield 446	org/eclipse/osgi/framework/debug/EclipseDebugTrace:debugOptions	Lorg/eclipse/osgi/framework/debug/FrameworkDebugOptions;
    //   364: invokevirtual 516	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:isVerbose	()Z
    //   367: invokevirtual 487	java/lang/StringBuffer:append	(Z)Ljava/lang/StringBuffer;
    //   370: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   373: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   376: aload_0
    //   377: aload 9
    //   379: new 267	java/lang/StringBuffer
    //   382: dup
    //   383: ldc 15
    //   385: invokespecial 484	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   388: aload_0
    //   389: lload_2
    //   390: invokespecial 502	org/eclipse/osgi/framework/debug/EclipseDebugTrace:getFormattedDate	(J)Ljava/lang/String;
    //   393: invokevirtual 489	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   396: invokevirtual 482	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   399: invokespecial 508	org/eclipse/osgi/framework/debug/EclipseDebugTrace:writeComment	(Ljava/io/Writer;Ljava/lang/String;)V
    //   402: aload 9
    //   404: invokevirtual 465	java/io/Writer:flush	()V
    //   407: goto +38 -> 445
    //   410: astore 10
    //   412: aload 10
    //   414: invokevirtual 458	java/io/IOException:printStackTrace	()V
    //   417: aload_1
    //   418: ifnull +37 -> 455
    //   421: aload_0
    //   422: aload 9
    //   424: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   427: goto +28 -> 455
    //   430: astore 11
    //   432: aload_1
    //   433: ifnull +9 -> 442
    //   436: aload_0
    //   437: aload 9
    //   439: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   442: aload 11
    //   444: athrow
    //   445: aload_1
    //   446: ifnull +9 -> 455
    //   449: aload_0
    //   450: aload 9
    //   452: invokespecial 500	org/eclipse/osgi/framework/debug/EclipseDebugTrace:closeWriter	(Ljava/io/Writer;)V
    //   455: aload_0
    //   456: aload_0
    //   457: dup
    //   458: getfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   461: iconst_1
    //   462: iadd
    //   463: dup_x1
    //   464: putfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   467: aload_0
    //   468: getfield 439	org/eclipse/osgi/framework/debug/EclipseDebugTrace:maxTraceFiles	I
    //   471: irem
    //   472: putfield 437	org/eclipse/osgi/framework/debug/EclipseDebugTrace:backupTraceFileIndex	I
    //   475: iload 4
    //   477: ireturn
    // Line number table:
    //   Java source line #402	-> byte code offset #0
    //   Java source line #403	-> byte code offset #3
    //   Java source line #404	-> byte code offset #10
    //   Java source line #405	-> byte code offset #21
    //   Java source line #406	-> byte code offset #37
    //   Java source line #409	-> byte code offset #43
    //   Java source line #410	-> byte code offset #48
    //   Java source line #411	-> byte code offset #61
    //   Java source line #412	-> byte code offset #110
    //   Java source line #413	-> byte code offset #113
    //   Java source line #415	-> byte code offset #142
    //   Java source line #416	-> byte code offset #153
    //   Java source line #417	-> byte code offset #161
    //   Java source line #418	-> byte code offset #169
    //   Java source line #419	-> byte code offset #196
    //   Java source line #420	-> byte code offset #235
    //   Java source line #421	-> byte code offset #262
    //   Java source line #422	-> byte code offset #265
    //   Java source line #423	-> byte code offset #274
    //   Java source line #429	-> byte code offset #277
    //   Java source line #430	-> byte code offset #285
    //   Java source line #431	-> byte code offset #290
    //   Java source line #432	-> byte code offset #299
    //   Java source line #439	-> byte code offset #302
    //   Java source line #441	-> byte code offset #305
    //   Java source line #442	-> byte code offset #312
    //   Java source line #443	-> byte code offset #339
    //   Java source line #444	-> byte code offset #348
    //   Java source line #445	-> byte code offset #376
    //   Java source line #446	-> byte code offset #402
    //   Java source line #447	-> byte code offset #407
    //   Java source line #448	-> byte code offset #412
    //   Java source line #450	-> byte code offset #417
    //   Java source line #451	-> byte code offset #421
    //   Java source line #449	-> byte code offset #430
    //   Java source line #450	-> byte code offset #432
    //   Java source line #451	-> byte code offset #436
    //   Java source line #453	-> byte code offset #442
    //   Java source line #450	-> byte code offset #445
    //   Java source line #451	-> byte code offset #449
    //   Java source line #454	-> byte code offset #455
    //   Java source line #458	-> byte code offset #475
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	478	0	this	EclipseDebugTrace
    //   0	478	1	traceFile	File
    //   0	478	2	timestamp	long
    //   1	475	4	isBackupOK	boolean
    //   41	77	5	traceFileName	String
    //   46	101	6	backupFilename	String
    //   151	175	7	backupFile	File
    //   283	3	8	isRenameOK	boolean
    //   303	148	9	traceWriter	Writer
    //   410	3	10	ioEx	IOException
    //   430	13	11	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   305	407	410	java/io/IOException
    //   305	417	430	finally
  }
  
  private void writeComment(Writer traceWriter, String comment)
    throws IOException
  {
    StringBuffer commentText = new StringBuffer("#");
    commentText.append(" ");
    commentText.append(comment);
    commentText.append(LINE_SEPARATOR);
    traceWriter.write(commentText.toString());
  }
  
  private final String getFormattedDate(long timestamp)
  {
    return TRACE_FILE_DATE_FORMATTER.format(new Date(timestamp));
  }
  
  /* Error */
  private final String getFormattedThrowable(Throwable error)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aload_1
    //   3: ifnull +63 -> 66
    //   6: aconst_null
    //   7: astore_3
    //   8: new 254	java/io/ByteArrayOutputStream
    //   11: dup
    //   12: invokespecial 449	java/io/ByteArrayOutputStream:<init>	()V
    //   15: astore 4
    //   17: new 258	java/io/PrintStream
    //   20: dup
    //   21: aload 4
    //   23: iconst_0
    //   24: invokespecial 462	java/io/PrintStream:<init>	(Ljava/io/OutputStream;Z)V
    //   27: astore_3
    //   28: aload_1
    //   29: aload_3
    //   30: invokevirtual 492	java/lang/Throwable:printStackTrace	(Ljava/io/PrintStream;)V
    //   33: aload 4
    //   35: invokevirtual 450	java/io/ByteArrayOutputStream:toString	()Ljava/lang/String;
    //   38: invokestatic 510	org/eclipse/osgi/framework/debug/EclipseDebugTrace:encodeText	(Ljava/lang/String;)Ljava/lang/String;
    //   41: astore_2
    //   42: goto +16 -> 58
    //   45: astore 5
    //   47: aload_3
    //   48: ifnull +7 -> 55
    //   51: aload_3
    //   52: invokevirtual 461	java/io/PrintStream:close	()V
    //   55: aload 5
    //   57: athrow
    //   58: aload_3
    //   59: ifnull +7 -> 66
    //   62: aload_3
    //   63: invokevirtual 461	java/io/PrintStream:close	()V
    //   66: aload_2
    //   67: areturn
    // Line number table:
    //   Java source line #496	-> byte code offset #0
    //   Java source line #497	-> byte code offset #2
    //   Java source line #498	-> byte code offset #6
    //   Java source line #500	-> byte code offset #8
    //   Java source line #501	-> byte code offset #17
    //   Java source line #502	-> byte code offset #28
    //   Java source line #503	-> byte code offset #33
    //   Java source line #504	-> byte code offset #42
    //   Java source line #505	-> byte code offset #47
    //   Java source line #506	-> byte code offset #51
    //   Java source line #508	-> byte code offset #55
    //   Java source line #505	-> byte code offset #58
    //   Java source line #506	-> byte code offset #62
    //   Java source line #510	-> byte code offset #66
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	68	0	this	EclipseDebugTrace
    //   0	68	1	error	Throwable
    //   1	66	2	result	String
    //   7	56	3	throwableStream	java.io.PrintStream
    //   15	19	4	throwableByteOutputStream	java.io.ByteArrayOutputStream
    //   45	11	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   8	45	45	finally
  }
  
  private void writeSession(Writer traceWriter, long timestamp)
    throws IOException
  {
    writeComment(traceWriter, "!SESSION " + getFormattedDate(timestamp));
    writeComment(traceWriter, "version: 1.1");
    writeComment(traceWriter, "verbose: " + debugOptions.isVerbose());
    writeComment(traceWriter, "The following option strings are specified for this debug session:");
    String[] allOptions = FrameworkDebugOptions.getDefault().getAllOptions();
    for (int i = 0; i < allOptions.length; i++) {
      writeComment(traceWriter, "\t" + allOptions[i]);
    }
  }
  
  private void writeMessage(Writer traceWriter, FrameworkDebugTraceEntry entry)
    throws IOException
  {
    StringBuffer message = new StringBuffer("|");
    message.append(" ");
    message.append(encodeText(entry.getThreadName()));
    message.append(" ");
    message.append("|");
    message.append(" ");
    message.append(getFormattedDate(entry.getTimestamp()));
    message.append(" ");
    message.append("|");
    message.append(" ");
    if (!debugOptions.isVerbose())
    {
      message.append(encodeText(entry.getMessage()));
    }
    else
    {
      message.append(entry.getBundleSymbolicName());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(encodeText(entry.getOptionPath()));
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(entry.getClassName());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(entry.getMethodName());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(entry.getLineNumber());
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(encodeText(entry.getMessage()));
    }
    if (entry.getThrowable() != null)
    {
      message.append(" ");
      message.append("|");
      message.append(" ");
      message.append(getFormattedThrowable(entry.getThrowable()));
    }
    message.append(" ");
    message.append("|");
    message.append(LINE_SEPARATOR);
    if ((traceWriter != null) && (message != null)) {
      traceWriter.write(message.toString());
    }
  }
  
  private static String encodeText(String inputString)
  {
    if ((inputString == null) || (inputString.indexOf("|") < 0)) {
      return inputString;
    }
    StringBuffer tempBuffer = new StringBuffer(inputString);
    int currentIndex = tempBuffer.indexOf("|");
    while (currentIndex >= 0)
    {
      tempBuffer.replace(currentIndex, currentIndex + "|".length(), "&#124;");
      currentIndex = tempBuffer.indexOf("|");
    }
    return tempBuffer.toString();
  }
  
  private Writer logForStream(OutputStream output)
  {
    try
    {
      return new BufferedWriter(new OutputStreamWriter(output, "UTF-8"));
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
    return new BufferedWriter(new OutputStreamWriter(output));
  }
  
  private Writer openWriter(File traceFile)
  {
    Writer traceWriter = null;
    if (traceFile != null) {
      try
      {
        traceWriter = logForStream(secureAction.getFileOutputStream(traceFile, true));
      }
      catch (IOException localIOException)
      {
        traceWriter = logForStream(System.out);
      }
    } else {
      traceWriter = logForStream(System.out);
    }
    return traceWriter;
  }
  
  private void closeWriter(Writer traceWriter)
  {
    if (traceWriter != null)
    {
      try
      {
        traceWriter.close();
      }
      catch (IOException ioEx)
      {
        ioEx.printStackTrace();
      }
      traceWriter = null;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.debug.EclipseDebugTrace
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.debug;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.eclipse.osgi.service.debug.DebugTrace;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class FrameworkDebugOptions
  implements DebugOptions, ServiceTrackerCustomizer<DebugOptionsListener, DebugOptionsListener>
{
  private static final String OSGI_DEBUG = "osgi.debug";
  private static final String OSGI_DEBUG_VERBOSE = "osgi.debug.verbose";
  public static final String PROP_TRACEFILE = "osgi.tracefile";
  private final Object lock;
  private Properties options;
  private Properties disabledOptions;
  private static FrameworkDebugOptions singleton = null;
  private static final String OPTIONS = ".options";
  protected static final Map<String, DebugTrace> debugTraceCache = new HashMap();
  protected File outFile;
  protected boolean verboseDebug;
  private volatile BundleContext context;
  private volatile ServiceTracker<DebugOptionsListener, DebugOptionsListener> listenerTracker;
  
  /* Error */
  private FrameworkDebugOptions()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 467	java/lang/Object:<init>	()V
    //   4: aload_0
    //   5: new 241	java/lang/Object
    //   8: dup
    //   9: invokespecial 467	java/lang/Object:<init>	()V
    //   12: putfield 443	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:lock	Ljava/lang/Object;
    //   15: aload_0
    //   16: aconst_null
    //   17: putfield 446	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   20: aload_0
    //   21: aconst_null
    //   22: putfield 445	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:disabledOptions	Ljava/util/Properties;
    //   25: aload_0
    //   26: aconst_null
    //   27: putfield 441	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:outFile	Ljava/io/File;
    //   30: aload_0
    //   31: iconst_1
    //   32: putfield 440	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:verboseDebug	Z
    //   35: aload_0
    //   36: ldc 10
    //   38: getstatic 437	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
    //   41: invokevirtual 460	java/lang/Boolean:toString	()Ljava/lang/String;
    //   44: invokestatic 518	org/eclipse/osgi/framework/internal/core/FrameworkProperties:getProperty	(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   47: invokestatic 461	java/lang/Boolean:valueOf	(Ljava/lang/String;)Ljava/lang/Boolean;
    //   50: invokevirtual 459	java/lang/Boolean:booleanValue	()Z
    //   53: putfield 440	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:verboseDebug	Z
    //   56: ldc 9
    //   58: invokestatic 517	org/eclipse/osgi/framework/internal/core/FrameworkProperties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   61: astore_1
    //   62: aload_1
    //   63: ifnonnull +4 -> 67
    //   66: return
    //   67: aload_0
    //   68: new 253	java/util/Properties
    //   71: dup
    //   72: invokespecial 494	java/util/Properties:<init>	()V
    //   75: putfield 446	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   78: aload_1
    //   79: invokevirtual 469	java/lang/String:length	()I
    //   82: ifne +60 -> 142
    //   85: ldc 12
    //   87: invokestatic 517	org/eclipse/osgi/framework/internal/core/FrameworkProperties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   90: getstatic 436	java/io/File:separatorChar	C
    //   93: bipush 47
    //   95: invokevirtual 472	java/lang/String:replace	(CC)Ljava/lang/String;
    //   98: astore_3
    //   99: aload_3
    //   100: ldc 5
    //   102: invokevirtual 476	java/lang/String:endsWith	(Ljava/lang/String;)Z
    //   105: ifne +23 -> 128
    //   108: new 243	java/lang/StringBuffer
    //   111: dup
    //   112: aload_3
    //   113: invokestatic 479	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   116: invokespecial 481	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   119: ldc 5
    //   121: invokevirtual 482	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   124: invokevirtual 480	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   127: astore_3
    //   128: new 229	java/io/File
    //   131: dup
    //   132: aload_3
    //   133: ldc 4
    //   135: invokespecial 454	java/io/File:<init>	(Ljava/lang/String;Ljava/lang/String;)V
    //   138: invokevirtual 451	java/io/File:toString	()Ljava/lang/String;
    //   141: astore_1
    //   142: aload_1
    //   143: iconst_0
    //   144: invokestatic 509	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:buildURL	(Ljava/lang/String;Z)Ljava/net/URL;
    //   147: astore_2
    //   148: aload_2
    //   149: ifnonnull +26 -> 175
    //   152: getstatic 438	java/lang/System:out	Ljava/io/PrintStream;
    //   155: new 243	java/lang/StringBuffer
    //   158: dup
    //   159: ldc 7
    //   161: invokespecial 481	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   164: aload_1
    //   165: invokevirtual 482	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   168: invokevirtual 480	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   171: invokevirtual 458	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   174: return
    //   175: getstatic 438	java/lang/System:out	Ljava/io/PrintStream;
    //   178: new 243	java/lang/StringBuffer
    //   181: dup
    //   182: ldc 6
    //   184: invokespecial 481	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   187: aload_2
    //   188: invokevirtual 488	java/net/URL:toExternalForm	()Ljava/lang/String;
    //   191: invokevirtual 482	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   194: invokevirtual 480	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   197: invokevirtual 457	java/io/PrintStream:print	(Ljava/lang/String;)V
    //   200: aload_2
    //   201: invokevirtual 484	java/net/URL:openStream	()Ljava/io/InputStream;
    //   204: astore_3
    //   205: aload_0
    //   206: getfield 446	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   209: aload_3
    //   210: invokevirtual 495	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   213: getstatic 438	java/lang/System:out	Ljava/io/PrintStream;
    //   216: ldc 2
    //   218: invokevirtual 458	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   221: goto +12 -> 233
    //   224: astore 4
    //   226: aload_3
    //   227: invokevirtual 456	java/io/InputStream:close	()V
    //   230: aload 4
    //   232: athrow
    //   233: aload_3
    //   234: invokevirtual 456	java/io/InputStream:close	()V
    //   237: goto +31 -> 268
    //   240: pop
    //   241: getstatic 438	java/lang/System:out	Ljava/io/PrintStream;
    //   244: ldc 3
    //   246: invokevirtual 458	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   249: goto +19 -> 268
    //   252: astore_3
    //   253: getstatic 438	java/lang/System:out	Ljava/io/PrintStream;
    //   256: ldc 1
    //   258: invokevirtual 458	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   261: aload_3
    //   262: getstatic 438	java/lang/System:out	Ljava/io/PrintStream;
    //   265: invokevirtual 455	java/io/IOException:printStackTrace	(Ljava/io/PrintStream;)V
    //   268: aload_0
    //   269: getfield 446	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   272: invokevirtual 498	java/util/Properties:keySet	()Ljava/util/Set;
    //   275: invokeinterface 532 1 0
    //   280: astore 4
    //   282: goto +34 -> 316
    //   285: aload 4
    //   287: invokeinterface 524 1 0
    //   292: astore_3
    //   293: aload_0
    //   294: getfield 446	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   297: aload_3
    //   298: aload_0
    //   299: getfield 446	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:options	Ljava/util/Properties;
    //   302: aload_3
    //   303: invokevirtual 499	java/util/Properties:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   306: checkcast 242	java/lang/String
    //   309: invokevirtual 471	java/lang/String:trim	()Ljava/lang/String;
    //   312: invokevirtual 502	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   315: pop
    //   316: aload 4
    //   318: invokeinterface 523 1 0
    //   323: ifne -38 -> 285
    //   326: return
    // Line number table:
    //   Java source line #57	-> byte code offset #0
    //   Java source line #36	-> byte code offset #4
    //   Java source line #38	-> byte code offset #15
    //   Java source line #40	-> byte code offset #20
    //   Java source line #48	-> byt
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

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