Sun的这个java.lang.Throwable 源码 设计非常糟糕,完全没有扩展性,

我在IBM 的Java JDK下,继承java.lang.Throwable重新定义了一个ExceptionWrapper,重载了java.lang.Throwable的大部分方法,

目的就是,不用Java本身的那种堆栈信息,大家知道的,Java本身的堆栈信息冗余性非常大,点击一个Action报错就上百行,当时真正有价值的错误信息就几行。

IBM的JDK是可以重写java.lang.Throwable的方法的,但是Sun的JDK坑爹的是private的方法,重写不了!这种设计真是坑爹。

不只是我遇到这个问题,网上也有人再说,问题的详细描述如下:

Hello java gods!  I've no idea, whether this is the right forum to post my request to, but I hope, some sun java developers will read it and may be able to do the following change:  class Throwable, method void printStackTraceAsCause(PrintStream s, StackTraceElement[] causedTrace)  and  class Throwable, method void printStackTraceAsCause(PrintWriter s, StackTraceElement[] causedTrace)  are both declared private. This should be protected, because we are developing a client server environment where exceptions are transferred over the network and for several reasons, I use a special own StackTraceElement. This is necessary, because the original StackTraceElements are created "magically" by the VM and cannot be constructed by normal code. Additionally, I need more information and have added fields to my own RemoteStackTraceElement.  Well, if the above methods were protected instead of private, it would always execute my methods instead of the original ones, if one of my Exceptions is in the list of causes. This means, I could encapsulate my exception the following way, which is sometimes needed, e.g. in Listeners:  void methodGivenByInterface() throws ExceptionGivenByInterface {   try {     client.execCmd(...);   } catch (RemoteException x) {     throw new ExceptionGivenByInterface(x);   } }  If the method that executes myMethod does a printStackTrace, it executes the one of ExceptionGivenByInterface. Because my RemoteException is the cause, the printStackTraceAsCause of it will be executed. But because it is declared private in Throwable, it does not execute my own printStackTraceAsCause but the one of Throwable.  I hope, I could make clear, why it is necessary to change private to protected, and I hope, someone finds the time to change this one word at both methods   Thousand thanks in advance for getting a protected Throwable.printStackTraceAsCause in j2sdk1.5x!  Best regards, Marco

坑爹的Sun JDK的更多相关文章

  1. 无cookie下载Oracle otn上的sun jdk等软件

    从Oracle下载sun jdk提示:In order to download products from Oracle Technology Network you must agree to th ...

  2. 第一章 删掉centos原有的openjdk并安装sun jdk

    一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111 ...

  3. Ubuntu安装Sun JDK及如何设置默认java JDK

    假设系统为Ubuntu 10.10 64位.    先来看看当前的系统默认的java版本,及提供商.通过命令java -version       kemix@kemix-VB10-64:~$ jav ...

  4. CentOS 安装 Sun JDK

    1. 卸载原Open JDK 查看已安装包 rpm -qa | grep java 如果已经安装有Open JDK,可能会列出类似下面的内容: tzdata-java-2015e-.el6.noarc ...

  5. Sun jdk, Openjdk, Icedtea jdk关系

    转自: http://blog.chinaunix.net/uid-20648944-id-3204527.html Sun jdk与Openjdk版本发展历史如下图所示: 1.    Openjdk ...

  6. openJdk和sun Jdk区别和安装

    openJdk和sun jdk的区别 使用过LINUX的人都应该知道,在大多数LINUX发行版本里,内置或者通过软件源安装JDK的话,都是安装的OpenJDK, 那么到底什么是OpenJDK,它与SU ...

  7. 删掉centos原有的openjdk并安装sun jdk

    [环境变量]删掉centos原有的openjdk并安装sun jdk   一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e ...

  8. 【环境变量】删掉centos原有的openjdk并安装sun jdk

    一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111 ...

  9. Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI

    # First verify the version of Java being used is not SunJSK. java -version   # Get the latest Sun Ja ...

随机推荐

  1. Linux下移植QT(2)---移植QT

    准备:ubantu12.04   内核 3.0.8(最好用同样的内核,3.2.0时没成功) 交叉编译工具:arm-cortex_a8-linux-gnueabi-gcc-4.4.6 QT版本5.4.2 ...

  2. 在多台PC之间同步Resharper所有设置的方法

    默认情况下Resharper只允许导出CodeStyle的设置,对于其它的设置不能导出,这样在不利用我们在多台PC之间同步Resharper的设置,经过多次尝试和Google找到了一种解决办法: Re ...

  3. javascript 连等赋值问题

    var a = {n:1}; var b = a; // 持有a,以回查 a.x = a = {n:2}; alert(a.x);// --> undefined alert(b.x);// - ...

  4. php 大文件上传的实现

    最近公司做工程项目,实现大文件上传 网上找了很久,发现网上很多代码大都存在很多问题,不过还是让我找到了一个符合要求的项目. 工程: 对项目的文件上传功能做出分析,找出文件上传的原理,对文件的传输模式深 ...

  5. python advanced programming ( II )

    面向对象编程 简称OOP,是一种程序设计思想.OOP把对象作为程序的基本单元,一个对象包含了数据和操作数据的函数.数据封装.继承和多态是面向对象的三大特点. 在Python中,所有数据类型都可以视为对 ...

  6. leetcode - [7]Binary Tree Preorder Traversal

    Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tr ...

  7. How to resolve "your security settings have blocked an untrusted application from running" in Mac

    If you encounter the error "your security settings have blocked an untrusted application from r ...

  8. (树状数组+离散化)lines--hdu --5124

    http://acm.hdu.edu.cn/showproblem.php?pid=5124 lines Time Limit: 5000/2500 MS (Java/Others)    Memor ...

  9. CGLIB介绍

    一.什么是CGLIB? CGLIB是一个功能强大,高性能的代码生成包.它为没有实现接口的类提供代理,为JDK的动态代理提供了很好的补充.通常可以使用Java的动态代理创建代理,但当要代理的类没有实现接 ...

  10. PAT甲级 1122. Hamiltonian Cycle (25)

    1122. Hamiltonian Cycle (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...