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. idea在哪执行maven clean?

  2. Win7 VS2013环境编译CGAL-4.7

    看到有人在QQ空间感叹编译CGAL配置折腾了一天时间,自己也想试试,虽然并不打算用,但感觉这库也挺有名的,想必日后用得着,于是着手试着编译. 首先是看一下官网的windows下配置说明 http:// ...

  3. rm与管道使用

    一 问题初始:用通常意义的管道使用这样可以:(1)ls -l | sed -n '/~$/p' 我用显示出系统自己建立的备份文件这时,我想删除这些文件,我仍然使用了管道,并执行了以下命令(2)ls - ...

  4. IntelliJ IDEA 2017版 spring-boot2.0.4的yml配置使用

    一.必须配置字端两个 server: port: 8080 servlet: context-path: /demo 二.两种mvc转换springboot,一种是注解,一种就是.yml或proper ...

  5. Calendar 得到前一天当前时间

    @Test public void test(){ //因为Calendar的构造方法是私有的,所以实例化一个Calendar对象用getInstance方法 Calendar calendar = ...

  6. SQL编写-谁和谁是好朋友

    problem: 用户表 姓名 张三 李四 王五       好友表   姓名 好友姓名 张三 李四 张三 王五 李四 张三 用户表里面姓名必须在好友表里面互加为好友,请问如何找出还没有加为好友的姓名 ...

  7. linux systemctl 常用用法简介

    主要介绍systemctl的几个功能如下: 1.查看某个服务的状态 2.关闭某个服务 3.开启某个服务 4.设置某个为开机自启动 5.关闭某个服务为开机不启动 6.查看所有开启启动的服务 1.查看某个 ...

  8. centos常用命令--备份

    端口打开 命令如下:/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT #8080为指定端口 /etc/rc.d/init.d/iptables ...

  9. 机器学习之Apriori算法和FP-growth算法

    1 关联分析 无监督机器学习方法中的关联分析问题.关联分析可以用于回答"哪些商品经常被同时购买?"之类的问题. 2 Apriori算法   频繁项集即出现次数多的数据集   支持度 ...

  10. 20155326刘美岑 2016-2017-2 《Java程序设计》第二周学习总结

    20155326刘美岑 2016-2017-2 <Java程序设计>第二周学习总结 教材学习内容总结 教材第三章主要讲解的是基础语法,主要包括认识类型与变量.学习运算符的基本使用.了解类型 ...