< prev index next >

src/hotspot/share/classfile/javaClasses.hpp

Print this page
rev 56353 : 8218628: Add detailed message to NullPointerException describing what is null.
Summary: This is the implementation of JEP 358: Helpful NullPointerExceptions.
Reviewed-by: coleenp, clanger, rschmelter, rriggs, forax


 502 
 503 class java_lang_Throwable: AllStatic {
 504   friend class BacktraceBuilder;
 505   friend class BacktraceIterator;
 506 
 507  private:
 508   // Offsets
 509   enum {
 510     hc_backtrace_offset     =  0,
 511     hc_detailMessage_offset =  1,
 512     hc_cause_offset         =  2,  // New since 1.4
 513     hc_stackTrace_offset    =  3   // New since 1.4
 514   };
 515   // Trace constants
 516   enum {
 517     trace_methods_offset = 0,
 518     trace_bcis_offset    = 1,
 519     trace_mirrors_offset = 2,
 520     trace_names_offset   = 3,
 521     trace_next_offset    = 4,
 522     trace_size           = 5,

 523     trace_chunk_size     = 32
 524   };
 525 
 526   static int backtrace_offset;
 527   static int detailMessage_offset;
 528   static int stackTrace_offset;
 529   static int depth_offset;
 530   static int static_unassigned_stacktrace_offset;
 531 
 532   // StackTrace (programmatic access, new since 1.4)
 533   static void clear_stacktrace(oop throwable);
 534   // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
 535   static void set_stacktrace(oop throwable, oop st_element_array);
 536   static oop unassigned_stacktrace();
 537 
 538  public:
 539   // Backtrace
 540   static oop backtrace(oop throwable);
 541   static void set_backtrace(oop throwable, oop value);
 542   static int depth(oop throwable);


 552   static void print_stack_usage(Handle stream);
 553 
 554   static void compute_offsets();
 555   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 556 
 557   // Allocate space for backtrace (created but stack trace not filled in)
 558   static void allocate_backtrace(Handle throwable, TRAPS);
 559   // Fill in current stack trace for throwable with preallocated backtrace (no GC)
 560   static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
 561   // Fill in current stack trace, can cause GC
 562   static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
 563   static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
 564   // Programmatic access to stack trace
 565   static void get_stack_trace_elements(Handle throwable, objArrayHandle stack_trace, TRAPS);
 566   // Printing
 567   static void print(oop throwable, outputStream* st);
 568   static void print_stack_trace(Handle throwable, outputStream* st);
 569   static void java_printStackTrace(Handle throwable, TRAPS);
 570   // Debugging
 571   friend class JavaClasses;


 572 };
 573 
 574 
 575 // Interface to java.lang.reflect.AccessibleObject objects
 576 
 577 class java_lang_reflect_AccessibleObject: AllStatic {
 578  private:
 579   // Note that to reduce dependencies on the JDK we compute these
 580   // offsets at run-time.
 581   static int override_offset;
 582 
 583   static void compute_offsets();
 584 
 585  public:
 586   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 587 
 588   // Accessors
 589   static jboolean override(oop reflect);
 590   static void set_override(oop reflect, jboolean value);
 591 




 502 
 503 class java_lang_Throwable: AllStatic {
 504   friend class BacktraceBuilder;
 505   friend class BacktraceIterator;
 506 
 507  private:
 508   // Offsets
 509   enum {
 510     hc_backtrace_offset     =  0,
 511     hc_detailMessage_offset =  1,
 512     hc_cause_offset         =  2,  // New since 1.4
 513     hc_stackTrace_offset    =  3   // New since 1.4
 514   };
 515   // Trace constants
 516   enum {
 517     trace_methods_offset = 0,
 518     trace_bcis_offset    = 1,
 519     trace_mirrors_offset = 2,
 520     trace_names_offset   = 3,
 521     trace_next_offset    = 4,
 522     trace_hidden_offset  = 5,
 523     trace_size           = 6,
 524     trace_chunk_size     = 32
 525   };
 526 
 527   static int backtrace_offset;
 528   static int detailMessage_offset;
 529   static int stackTrace_offset;
 530   static int depth_offset;
 531   static int static_unassigned_stacktrace_offset;
 532 
 533   // StackTrace (programmatic access, new since 1.4)
 534   static void clear_stacktrace(oop throwable);
 535   // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed)
 536   static void set_stacktrace(oop throwable, oop st_element_array);
 537   static oop unassigned_stacktrace();
 538 
 539  public:
 540   // Backtrace
 541   static oop backtrace(oop throwable);
 542   static void set_backtrace(oop throwable, oop value);
 543   static int depth(oop throwable);


 553   static void print_stack_usage(Handle stream);
 554 
 555   static void compute_offsets();
 556   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 557 
 558   // Allocate space for backtrace (created but stack trace not filled in)
 559   static void allocate_backtrace(Handle throwable, TRAPS);
 560   // Fill in current stack trace for throwable with preallocated backtrace (no GC)
 561   static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
 562   // Fill in current stack trace, can cause GC
 563   static void fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS);
 564   static void fill_in_stack_trace(Handle throwable, const methodHandle& method = methodHandle());
 565   // Programmatic access to stack trace
 566   static void get_stack_trace_elements(Handle throwable, objArrayHandle stack_trace, TRAPS);
 567   // Printing
 568   static void print(oop throwable, outputStream* st);
 569   static void print_stack_trace(Handle throwable, outputStream* st);
 570   static void java_printStackTrace(Handle throwable, TRAPS);
 571   // Debugging
 572   friend class JavaClasses;
 573   // Gets the method and bci of the top frame (TOS). Returns false if this failed.
 574   static bool get_top_method_and_bci(oop throwable, Method** method, int* bci);
 575 };
 576 
 577 
 578 // Interface to java.lang.reflect.AccessibleObject objects
 579 
 580 class java_lang_reflect_AccessibleObject: AllStatic {
 581  private:
 582   // Note that to reduce dependencies on the JDK we compute these
 583   // offsets at run-time.
 584   static int override_offset;
 585 
 586   static void compute_offsets();
 587 
 588  public:
 589   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 590 
 591   // Accessors
 592   static jboolean override(oop reflect);
 593   static void set_override(oop reflect, jboolean value);
 594 


< prev index next >