United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4712607 RFE: StackTraceElement class should have a public constructor
JDK-4712607 : RFE: StackTraceElement class should have a public constructor

Details
Type:
Enhancement
Submit Date:
2002-07-10
Status:
Resolved
Updated Date:
2003-08-15
Project Name:
JDK
Resolved Date:
2003-08-15
Component:
core-libs
OS:
windows_xp,windows_2000
Sub-Component:
java.lang
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.1
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

Description

Name: rmT116609			Date: 07/10/2002


FULL PRODUCT VERSION :
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)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

DESCRIPTION OF THE PROBLEM :
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.

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

Name: rmT116609			Date: 11/14/2002


DESCRIPTION OF THE PROBLEM :
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)
======================================================================

                                    

Comments
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
                                     
2002-07-24
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b16


                                     
2004-06-14



Hardware and Software, Engineered to Work Together