JDK-4712607 : RFE: StackTraceElement class should have a public constructor
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2002-07-10
  • Updated: 2017-05-16
  • Resolved: 2003-08-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
5.0 tigerFixed

Name: rmT116609			Date: 07/10/2002

java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)

Microsoft Windows 2000 [Version 5.00.2195]

The StackTraceElement class has a private constructor, so it cannot be instantiated by an application.

This is much restrictive. We are working on a application which parses a XML file previously generated by the logging API (java.util.logging). After parsing the file, it recreates a java.util.logging.LogRecord instance for each
log record in the file.

When the log record includes stack trace information of an exception, we can recreate the Exception, and it even has a setStackTrace method, but we can't create the StackTraceElement instances it needs.

We could have stopped using LogRecord altogether, but we prefer to use it so we can use other facilities from the logging package (Filters, etc.). Either way, to represent the stack trace we'd have to define a new class (which we
did as a workaround, and used the Parameters field of the LogRecord to store it).

Furthermore, we can't see any real problem if this class has a public constructor.

Create a new StackTraceElement class (with the same information, but public constructor) in the application.
(Review ID: 158647) 

Name: rmT116609			Date: 11/14/2002

Java code is often generated as intermediate code by Application Generators. Jidl is one such application, but there are others and we happen to be writing one.

It would be nice to display stack traces in terms of the original non-java code files. This would require catching an exception in the generated java code and substituting a StackTraceElement that refers to the original file. This is
relatively straight forward for an Application Generator to do but it requires that a new StackTraceElement is generated. This is currently impossible as
StackTraceElement has a private constructor and no factory methods.

I can think of no situation where the ability to create StackTraceElements and substitute them into the stack trace for a Throwable might cause a security breach.

Please make the constructor for StackTraceElement public.

(Review ID: 166939)

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b16

EVALUATION We were probably being a bit paranoid when we intentionally prevented construction of StackTraceElement instances. This seems like a reasonable (and simple) request. ###@###.### 2002-07-24