Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4361055

javadoc: Fails to resolve @see and @link references to package-private methods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.3.0
    • tools

      ame + " user: "
                  + props.getProperty("user.name"));
              printInfo("Working directory: "
                  + props.getProperty("user.dir"));
              StringBuffer envInfo = new StringBuffer();

              if (osName.toUpperCase().startsWith("WINDOWS"))
                  NTcommand.run("cmd /c set", envInfo);
              else
                  NTcommand.run("set", envInfo);
              
              printHeadline("ENVIRONMENT:");
              printInfo(envInfo.toString());
          }
          
          /**
          * Prints the supplied string, "underlined" with a following line
      hyphens.
          * @param headline the string to print.
          */
          public void printHeadline(String headline)
          {
              printInfo(headline);
              StringBuffer underline = new StringBuffer(headline);
              for (int i=0; i < underline.length(); i++)
                  underline.setCharAt(i, '-');
              printInfo(underline.toString());
          }

          /**
          * Prints VM thread and memory usage.
          * @param prefix text to prefix the report.
          */
          public void printVMinfo(String prefix)
          {
              Runtime rt = Runtime.getRuntime();
              printInfo(prefix
                   + "threads=" + Thread.activeCount()
                   + " memory=" + (1+rt.freeMemory())/1024
                   + "/" + rt.totalMemory()/1024
                   + " (KB free/total)"
                   );
          }
          
          /**
          * Print report showing throwable and stack trace.
          * @param e Throwable to print.
          * @param text is prepended to " - " + e.toString
          */
          public void printThrowable(String text, Throwable e)
      {
      printInfo(text + " - " + throwableToString(e));
      }

      /**
      * @param e Throwable to print.
      * @return Formatted stack trace.
      */
      public static String throwableToString(Throwable e)
      {
      final boolean AUTO_FLUSH = true;
      final java.io.StringWriter sw = new java.io.StringWriter();
              e.printStackTrace(new java.io.PrintWriter(sw, AUTO_FLUSH));
              return sw.toString();
      }

          /**
          * Open optional log file. All the other <i>logfile</i> methods
          * a) operate on this logfile, and b) are ignored if there isn't one open.
          * @see #printInfo(int, String)
          * @param newLogFile the file to open.
          */
          public void openLogfile(File newLogFile)
          {
              logFile = newLogFile;
              openLogfile();
          }
          private void openLogfile()
          {
              FileOutputStream logFileOutputStream = null;
              if (logFile == null)
                  return;
              String name = logFile.getAbsolutePath();
              printInfo(2, "openLogfile() ... name=" + name);
              
              // Open logfile
              try
              {
                  // There's no single method to open-or-create a file!!
                  if (logFile.isFile())
                      // Have to use name-based opening of existing file to allow
      append option.
                      logFileOutputStream = new FileOutputStream(name, true);
                  else
                      logFileOutputStream = new FileOutputStream(logFile);
                      
                  logFileFD = logFileOutputStream.getFD();
              }
              catch (FileNotFoundException e)
              {
                  // Should never happen!
                  printInfo("LOGIC ERROR! Failed to create: " + name + " - " + e);
                  return;
              }
              catch (IOException e)
              {
                  // eg: No write access
                  printInfo("ERROR! Can't write to: " + name + " - " + e);
                  return;
              }
              logFilePrintWriter = new PrintWriter(logFileOutputStream, true);
          }

          /**
          * Switch (&quot;spin&quot;) to a new logfile if current one is too big.
          */
          public void spinLogfileIfTooBig()
          {
              if (logFile == null)
                  return;
              String name = logFile.getAbsolutePath();
              
              printInfo(3, "spinLogfileIfTooBig() called, size="
                      + getLogfileLength() + " last modified: " + formatDateAndTime(
                          new java.util.Date(logFile.lastModified()),
                          "HH:mm:ss dd-MMM-yy")
                      );
              long len = getLogfileLength();
              if (len < maxLogFileKB * 1024L)
                  return; // No spin needed
              spinLogfile("file too big (" + len + " bytes)");
          }
          /**
          * Switch (&quot;spin&quot;) logfile.
          * The current logfile is closed and renamed (with a name of the form:
          *
      <i>oldname</i><code>-<i>yyyy</i>_<i>MMM</i>_<i>dd</i>_<i>HH</i>_<i>mm</i></code>
      )
          * and a new file created and opened.
          * @param msg Message to write at end of old file.
          */
          synchronized public void spinLogfile(String msg)
          {
              if (logFile == null)
                  return;
              String name = logFile.getAbsolutePath();
              String newName = name + "-" + getTimeStamp("yyyy_MMM_dd_HH_mm");
              File renamedFile = new File(newName);
              
              printReportStart();
              printInfo("\"spinning\" logfile - " + msg);
              
              if (renamedFile.exists())
                  printInfo("ERROR! spun logfile already exists: " + newName);
              else
              {
                  printInfo("Saving current log as: " + newName);
                  // NOTE: The logic here is more complex than would be necessary for
                  // a pure Unix implementation, since NT doesn't allow you to rename
                  // an open file (Unix does).
                  String s;
                  logFilePrintWriter.close();
                  if (logFile.renameTo(renamedFile))
                      s = "logfile \"spun\" OK; previous file saved as: " + newName;
                  else
                  {
                      s = "ERROR! failed to rename " + name + " to " + newName;
                      System.err.println(s);
                      // The openLogfile below will re-open the current log.
                  }
                  openLogfile(); // re-open
                  printInfo(s);
              }
              printReportEnd();
          }
          
          /**
          * @return current size of logfile, or -1 on any error.
          */
          public long getLogfileLength()
          {
              if (logFile == null)
                  return -1;
              // Don't bother with syncLogfile for these informational calls.
              return logFile.length();
          }
          
          /**
          * @return {@link java.io.File#lastModified()} time of the logfile.
          * The time is a system-dependent value, but, on NT at least, is the same as
          * <code>java.lang.System.currentTimeMillis()</code>.
          * @param sync set to true to use {@link #syncLogfile()}
          * to get the most accurate value, rather than
          * the one the VM may have cached.
          */
          public long getLogfileLastModified(boolean sync)
          {
              if (logFile == null)
                  return 0;
              if (sync)
                  syncLogfile();
              return logFile.lastModified();
          }
          
          
          /**
          * Called to ensure that the logFile {@link java.io.File}'s status is
      up-to-date.
          * <BR>
          * This method is required, since, on NT, many java.io.File methods
          * (such as {@link java.io.File#length()}) may not reflect the true
          * filesytem values. This is definitely the case if the JVM currently
          * has the same file open (when it appears to use it's buffered view of the
      file).
          * <BR>
          * The fix for this is to maintain a {@link java.io.FileDescriptor} to any
          * open {@link java.io.File} and use it's sync() method before any File
      methods!
          */
          protected void syncLogfile()
          {
              if (logFileFD != null) try
              {
                  logFileFD.sync();
              }
              catch (SyncFailedException e) {} // Ignore this
          }
          
          /**
          * @return TRUE if a logfile is currently being used.
          */
          public boolean writingToLogFile()
          {
              return (logFileFD != null);
          }
      }
      ---------------- END SOURCE FILE -------------------
      (Review ID: 108159)
      ======================================================================
      Name: skT45625 Date: 08/09/2000
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      Javadoc fails to resolve some @see and @link references.
      This has been happening on every release I've ever tried (from 1.1.5).
      For instance, javadoc'ing the file inserted below fails to resolve the links to
      #setDefaultDateFormat(String), reporting:


      Generating com/drkb/service/javadocs\index-all.html...
      javadoc: warning - com.drkb.service.Log.formatDateAndTime(long): Tag @see: can't
      find setDefaultDateFormat(String) in com.drkb.service.Log
      javadoc: warning - com.drkb.service.Log.getTimeStamp(): Tag @see: can't find
      setDefaultDateFormat(String simpleDateFormat) in com.drkb.service.Log
      javadoc: warning - com.drkb.service.Log.getTimeStamp(int): Tag @see: can't find
      setDefaultDateFormat(String) in com.drkb.service.Log
      Generating com/drkb/service/javadocs\deprecated-list.html...
      Building index for all classes...
      Generating com/drkb/service/javadocs\allclasses-frame.html...
      Generating com/drkb/service/javadocs\index.html...
      Generating com/drkb/service/javadocs\packages.html...
      Generating com/drkb/service/javadocs\com\drkb\service\package-summary.html...
      Generating com/drkb/service/javadocs\com\drkb\service\package-tree.html...
      Generating com/drkb/service/javadocs\com\drkb\service\package-frame.html...
      Generating com/drkb/service/javadocs\com\drkb\service\Log.html...
      javadoc: warning - com.drkb.service.Log: Tag @link: can't find
      setDefaultDateFormat(String) in com.drkb.service.Log
      javadoc: warning - com.drkb.service.Log: Tag @link: can't find
      setDefaultDateFormat(String) in com.drkb.service.Log

      ---------------- START SOURCE FILE -------------------
      package com.drkb.service;

      import java.util.*;
      import java.text.SimpleDateFormat;
      import java.io.*;

      /**
      * <font face="Arial">
      * Set of methods to support information logging (using {@link
      #printInfo(String)})
      * and management of one or more of:<ul>
      * <li> a logfile
      * <li> the NT Event log
      * <li> <i>stdout</i>
      * </ul>
      * </font>
      * <PRE>
      * <B>Modification History</B>
      * Aug-00 (1.0.2) Move majority of code into this class, leaving the
      * singleton {@link Logging} one untouched.
      * Add new methods: {@link #setDefaultDateFormat(String)},
      * {@link #printHeadline(String)} and {@link #setMaxLineLength(int)}.
      * Jun-00 Synchronize event log printInfo on this (was on System.out)
      * Mar-00 Synchronize event log printInfo too!
      * Feb-00 Synchronize printInfo on it's output stream(s).
      * </PRE>
      * @version 1.0.2
      * @author Peter Binney
      */
      public class Log
      {
          // Non-null if writing to logFile.
          PrintWriter logFilePrintWriter = null;
          
          PrintWriter stdoutPrintWriter = new PrintWriter(System.out, true);
          
          // Non-null if running as true service - should only be set
          // in singleton operation, since the NT Event log is a single stream.
          boolean runningAsService = false;

          private File logFile = null;
          private FileDescriptor logFileFD = null; // Always set when logFile
      non-null
          
          /**
          * Default size at which {@link #spinLogfileIfTooBig()} switches logfiles.
          * @see #setMaxLogFileKB(int)
          */
          public final int maxLogFileKB_DEFAULT = 100;
          private int maxLogFileKB = maxLogFileKB_DEFAULT;
          
          private int debug = 0;

          private int printReportNestingLevel = 0;
          
          private static final String DEFAULT_defaultDateFormat = "HH:mm:ss
      dd-MMM-yy";
          private static String defaultDateFormat = DEFAULT_defaultDateFormat;
          
          private int maxLineLength = 511;
          
          // Only default constructor required
          
          /**
          * @return current debug level.
          */
          public int getDebugLevel()
          {
              return debug;
          }
          /**
          * Sets the debug level which controls whether {@link #printInfo(int,
      String)}
          * calls with non-0 values are ignored.
          * @param newValue level to set
          * @return previous level.
          */
          public int setDebugLevel(int newValue)
          {
              int old = debug;
              debug = newValue;
              // System.out.println("Debug Level changed from " + old + " to " +
      debug);
              return old;
          }
          
          /**
          * @return the size which triggers {@link #spinLogfileIfTooBig()}.
          */
          public int getMaxLogFileKB()
          {
              return maxLogFileKB;
          }
          /**
          * @param newValue Sets the size which triggers {@link
      #spinLogfileIfTooBig()}.
          * @return previous level.
          */
          public int setMaxLogFileKB(int newValue)
          {
              int old = maxLogFileKB;
              maxLogFileKB = newValue;
              return old;
          }
          
          /**
          * When not writing to the Event log, very long lines are broken
          * (with <code>/... .../</code> at end/start of line) to make them readable
          * in editors with limited line length support (such as VIW.EXE).
          * The default length is 511 bytes, but this can be changed with this method.
          * @param newLength
          * @return the previous value
          */
          public int setMaxLineLength(int newLength)
          {
              int ret = maxLineLength;
              maxLineLength = newLength;
              return ret;
          }

          /**
          * Sets the default date format used by the various static
          * date formatting methods.
          * @param simpleDateFormat is a SimpleDateFormat string.
          * If this method isn't called
          * <CODE>&quot;HH:mm:ss dd-MMM-yy&quot;</CODE> is used.
          */
          static void setDefaultDateFormat(String simpleDateFormat)
          {
              defaultDateFormat = simpleDateFormat;
          }
          
          /**
      * @return standard current date/time formatted using the
      * default format.
      * @see #setDefaultDateFormat(String simpleDateFormat)
      */
          static public String getTimeStamp()
          {
              return getTimeStamp(defaultDateFormat);
          }
          
          /**
      * @return standard current date/time formatted as required.
          * @param formatString is a SimpleDateFormat string
          */
          static public String getTimeStamp(String formatString)
          {
              return formatDateAndTime(new java.util.Date(), formatString);
          }
          /**
      * @return standard current date/time formatted using the
      * default format.
      * @see #setDefaultDateFormat(String)
          * @param hoursFromGMT defaults to 0.
          */
          static public String getTimeStamp(int hoursFromGMT)
          {
              return formatDateAndTime(new java.util.Date(), hoursFromGMT);
          }

          /**
          * Formats supplied date/time (either <code>Date</code> or
          * <code>System.currentTimeMillis()</code>). Other optional parameters:
          * @param formatString is a SimpleDateFormat string
          * @param hoursFromGMT defaults to 0.
      * @see #setDefaultDateFormat(String)
          */
          static public String formatDateAndTime(long millis)
          {
              return formatDateAndTime(new Date(millis), 0);
          }
          static public String formatDateAndTime(java.util.Date date, int
      hoursFromGMT)
          {
              return formatDateAndTime(date, hoursFromGMT, defaultDateFormat);
          }
          static public String formatDateAndTime(Date date, String formatString)
          {
              return formatDateAndTime(date, 0, formatString);
          }
          public static String formatDateAndTime(java.util.Date date, int
      hoursFromGMT,
                          String formatString)
          {
              // CODING NOTE: don't use printInfo here, since it calls this!!

              // Make copy of passed date .... to a) allow timzones to
              // be set on a date-by-date basis (ie: don't affect
              // default system clock one) and b) to allow
              // ones passed from status.timezone[] array to have
              // timezone set.
              SimpleDateFormat f = new SimpleDateFormat(formatString);

              // System.out.println("formatDateAndTime called with: " + date
              // + " and offset=" + hoursFromGMT);
              TimeZone tz = (TimeZone)TimeZone.getDefault().clone();
              // Must force timezone
              tz.setRawOffset(hoursFromGMT * 60 * 60 * 1000);
              f.setTimeZone(tz);
              return f.format(date);
          }

          /**
          * Display timestamped message. Messages are always written to the
          * current logFile (assuming one's been been opened, with {@link
      #openLogfile(File)};
          * if it hasn't and we're not running as an NT Service, they're written to
      stdout).
          * <BR>
          * When running as an NT Service messages are also written to the Event log
          * (where line endings are always forced to be "\r\n", since if
          * there's no "\r" lines in each event are concatenated).
          * Event log lines also don't have a timestamp.
          * <BR>
          * <BR>eg: <PRE>
      * printInfo(&quot;Message always displayed&quot;)
      * printInfo(0, &quot;Message also always displayed&quot;)
      * printInfo(1, &quot;Message only displayed if debug level &gt;=
      1&quot;)</PRE>
          * @param msg is message to display.
          * @param debugLevel if present, only displays the message if the current
          * debugging level is at least the specified level.
          * @see #setMaxLineLength(int)
          */
          public void printInfo(int debugLevel, String msg)
          {
              printInfo(debugLevel, msg, true);
          }
          /** * @param msg See {@link #printInfo(int, String)}. */
          public void printInfo(String msg)
          {
              printInfo(0, msg);
          }

          // Real work done in private method whose additional flag
          // is false to suppress both EventLog output and timestamp.
          private boolean lastPrintInfoBlank = false;
          /** * @param debugLevel * @param msg * @param eventLogAndTimestamp */
          private void printInfo(int debugLevel, String msg, boolean
      eventLogAndTimestamp)
          {
              if (debug < debugLevel)
                  return; // Nothing needed
              String prefix = "";

              // Suppress ajacent blanks lines if called with eventLog unset
              if ((!eventLogAndTimestamp) && (msg.equals("")))
              {
                  if (lastPrintInfoBlank)
                      return;
                  lastPrintInfoBlank = true;
              }
              else
                  lastPrintInfoBlank = false;

              if (eventLogAndTimestamp)
                  prefix = getTimeStamp() + " ";
                  
              // Write to logfile if being used.
              if (logFilePrintWriter != null)
                  printLine(logFilePrintWriter, prefix + msg);

              // Write to stdout if logfile not being used,
              // or if in Service mode (when we dual-log to the Event log as well)
              if (runningAsService)
              {
                  if (eventLogAndTimestamp)
                      eventLogPrintln(msg);
              }
              else if (logFilePrintWriter == null)
                  printLine(stdoutPrintWriter, prefix + msg);
          }
          /*
          * Write output, breaking long lines as required.
          * @param pw
          * @param msg
          */
          private void printLine(PrintWriter pw, String msg)
          {
              char[] chars = (msg + "\n").toCharArray();
              int lineLen = 0;
              char lastChar = '\0';
              // System.err.println("printLine(\"" + msg + "\") chars.length=" +
      chars.length);
              synchronized (pw)
              {
                  for (int i=0; i < chars.length; lastChar = chars[i++])
                  {
                      // Line end on every '\n'
                      if (chars[i] == '\n')
                          pw.println("");
                      else
                          pw.print(chars[i]);
                       
                      if ((chars[i] == '\n') || (chars[i] == '\r'))
                          lineLen = 0;
                      else
                      {
                          lineLen++;
                          if (lineLen > maxLineLength)
                          {
                              pw.println(" /...");
                              pw.println("");
                              final String lineContinuation = ".../ ";
                              pw.print(lineContinuation);
                              lineLen = lineContinuation.length();
                          }
                      }
                  }
              }
          }
          
          /**
          * Pair of methods called around set of {@link #printInfo(String)} requests
          * that should be sent together when writing to the NT Event log.
          * <BR>
          * By default, each <code>printInfo</code>
          * (which just uses <code>System.out.println()</code>)
          * is written as a separate NT Event.
          * <BR>
          * These methods only affect NT Event logging.
          */
          public void printReportStart()
          {
              if (runningAsService)
              {
                  synchronized (this)
                  {
                      // Don't bother to turn off AutoDump if already nesting.
                      if (printReportNestingLevel++ < 1)
                          ServiceAid.setAutoDumpOutMode(false);
                  }
              }
              printInfo(0, "", false); // Blank line in all but Event log
          }
          public void printReportEnd()
          {
              if (runningAsService)
              {
                  synchronized (this)
                  { // If nested calls, only turn off AutoDump when "outer" call
      made.
                      if (--printReportNestingLevel < 1)
                      {
                          ServiceAid.setAutoDumpOutMode(true);
                          System.out.flush();
                      }
                  }
              }
              printInfo(0, "", false); // Blank line in all but Event log
          }
          
          /**
          * Called when in Service mode to do System.out.println with appropriate
          * line-end mapping.
          * @param msg Text line to write.
          */
          private void eventLogPrintln(String msg)
          {
              synchronized (this)
              {
                  boolean oldAutoDumpOut = ServiceAid.setAutoDumpOutMode(false);
                  char[] chars;
                  if (printReportNestingLevel > 0)
                      chars = (msg + "\n").toCharArray(); // In printReport add line
      endings.
                  else
                      chars = (msg).toCharArray();
                      
                  char lastChar = '\0';
                  for (int i=0; i < chars.length; lastChar = chars[i++])
                  {
                      // Line end on every '\n'
                      if (chars[i] == '\n')
                      {
                          if (lastChar != '\r')
                              System.out.print('\r');
                          System.out.println("");
                      }
                      else
                          System.out.print(chars[i]);
                  }
                  ServiceAid.setAutoDumpOutMode(oldAutoDumpOut);
                  // Only flush (force transaction end) if not
                  // within printReportStart/printReportEnd
                  if (oldAutoDumpOut)
                      System.out.flush();
              }
          }
          
      /**
      * Displays various environment variables.
      * Both the few available from System Properties
      * and by running a sub-process to see the Operating System ones.
      */
      public void printEnvironmentVariables()
      {
              Properties props = System.getProperties();
              String osName = props.getProperty("os.name");
              printHeadline("java.class.path:");
              printInfo(props.getProperty("java.class.path"));
              if (runningAsService && ServiceAid.CLASSPATHsetInVM != null)
              {
                  printHeadline("Microsoft VM's internal CLASSPATH set to:");
                  printInfo(ServiceAid.CLASSPATHsetInVM);
              }
              printInfo("Running as " + osN

            dkramersunw Douglas Kramer (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: