< prev index next >

src/java.base/share/classes/java/lang/StackTraceElement.java

Print this page




  57      * @param fileName the name of the file containing the execution point
  58      *         represented by the stack trace element, or {@code null} if
  59      *         this information is unavailable
  60      * @param lineNumber the line number of the source line containing the
  61      *         execution point represented by this stack trace element, or
  62      *         a negative number if this information is unavailable. A value
  63      *         of -2 indicates that the method containing the execution point
  64      *         is a native method
  65      * @throws NullPointerException if {@code declaringClass} or
  66      *         {@code methodName} is null
  67      * @since 1.5
  68      */
  69     public StackTraceElement(String declaringClass, String methodName,
  70                              String fileName, int lineNumber) {
  71         this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
  72         this.methodName     = Objects.requireNonNull(methodName, "Method name is null");
  73         this.fileName       = fileName;
  74         this.lineNumber     = lineNumber;
  75     }
  76 







  77     /**
  78      * Returns the name of the source file containing the execution point
  79      * represented by this stack trace element.  Generally, this corresponds
  80      * to the {@code SourceFile} attribute of the relevant {@code class}
  81      * file (as per <i>The Java Virtual Machine Specification</i>, Section
  82      * 4.7.7).  In some systems, the name may refer to some source code unit
  83      * other than a file, such as an entry in source repository.
  84      *
  85      * @return the name of the file containing the execution point
  86      *         represented by this stack trace element, or {@code null} if
  87      *         this information is unavailable.
  88      */
  89     public String getFileName() {
  90         return fileName;
  91     }
  92 
  93     /**
  94      * Returns the line number of the source line containing the execution
  95      * point represented by this stack trace element.  Generally, this is
  96      * derived from the {@code LineNumberTable} attribute of the relevant




  57      * @param fileName the name of the file containing the execution point
  58      *         represented by the stack trace element, or {@code null} if
  59      *         this information is unavailable
  60      * @param lineNumber the line number of the source line containing the
  61      *         execution point represented by this stack trace element, or
  62      *         a negative number if this information is unavailable. A value
  63      *         of -2 indicates that the method containing the execution point
  64      *         is a native method
  65      * @throws NullPointerException if {@code declaringClass} or
  66      *         {@code methodName} is null
  67      * @since 1.5
  68      */
  69     public StackTraceElement(String declaringClass, String methodName,
  70                              String fileName, int lineNumber) {
  71         this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
  72         this.methodName     = Objects.requireNonNull(methodName, "Method name is null");
  73         this.fileName       = fileName;
  74         this.lineNumber     = lineNumber;
  75     }
  76 
  77 
  78     /**
  79      * Creates an empty stack frame element to be filled in by Throwable.
  80      * @since 1.9
  81      */
  82     StackTraceElement() { }
  83 
  84     /**
  85      * Returns the name of the source file containing the execution point
  86      * represented by this stack trace element.  Generally, this corresponds
  87      * to the {@code SourceFile} attribute of the relevant {@code class}
  88      * file (as per <i>The Java Virtual Machine Specification</i>, Section
  89      * 4.7.7).  In some systems, the name may refer to some source code unit
  90      * other than a file, such as an entry in source repository.
  91      *
  92      * @return the name of the file containing the execution point
  93      *         represented by this stack trace element, or {@code null} if
  94      *         this information is unavailable.
  95      */
  96     public String getFileName() {
  97         return fileName;
  98     }
  99 
 100     /**
 101      * Returns the line number of the source line containing the execution
 102      * point represented by this stack trace element.  Generally, this is
 103      * derived from the {@code LineNumberTable} attribute of the relevant


< prev index next >