坑爹的Sun JDK
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的更多相关文章
- 无cookie下载Oracle otn上的sun jdk等软件
从Oracle下载sun jdk提示:In order to download products from Oracle Technology Network you must agree to th ...
- 第一章 删掉centos原有的openjdk并安装sun jdk
一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111 ...
- Ubuntu安装Sun JDK及如何设置默认java JDK
假设系统为Ubuntu 10.10 64位. 先来看看当前的系统默认的java版本,及提供商.通过命令java -version kemix@kemix-VB10-64:~$ jav ...
- CentOS 安装 Sun JDK
1. 卸载原Open JDK 查看已安装包 rpm -qa | grep java 如果已经安装有Open JDK,可能会列出类似下面的内容: tzdata-java-2015e-.el6.noarc ...
- Sun jdk, Openjdk, Icedtea jdk关系
转自: http://blog.chinaunix.net/uid-20648944-id-3204527.html Sun jdk与Openjdk版本发展历史如下图所示: 1. Openjdk ...
- openJdk和sun Jdk区别和安装
openJdk和sun jdk的区别 使用过LINUX的人都应该知道,在大多数LINUX发行版本里,内置或者通过软件源安装JDK的话,都是安装的OpenJDK, 那么到底什么是OpenJDK,它与SU ...
- 删掉centos原有的openjdk并安装sun jdk
[环境变量]删掉centos原有的openjdk并安装sun jdk 一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e ...
- 【环境变量】删掉centos原有的openjdk并安装sun jdk
一.卸载原有openjdk rpm -qa | grep java 之后,将展示出来的全部卸载掉,我这里是5个 rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111 ...
- 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 ...
随机推荐
- (9)How to take a picture of a black hole
https://www.ted.com/talks/katie_bouman_what_does_a_black_hole_look_like/transcript 00:13In the movie ...
- 查看mysql数据库中的所有用户
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user; @前面为用户名,后面对应的‘% ...
- js中对象继承的冒充方法
function Parent(name){ this.name = name; this.sayName = function(){ console.log(this.name); } } func ...
- 分布式的CAP理论
CAP是强一致性.可用性(实时可用).分区容忍性: Consistency(一致性). Availability(可用性).Partition tolerance(分区容错性) 一般来说 P 是前提. ...
- 在eclipse上搭建Roku开发环境
环境:Oracle VM virtualBox+Ubuntu server 12.0.4.2 LTS+xfce+ Eclipse IDE for C/C++ Developers 4.3.2 参考:h ...
- Node的关系型数据库ORM库:bookshelf
NodeJs 关系数据库ORM库:Bookshelf.js bookshelf.js是基于knex的一个关系型数据库的ORM库.简单易用,内置了Promise的支持.这里主要罗列一些使用的例子,例子就 ...
- stm32常识
cmsis全称Cortex Microcontroller Software Interface Standard,就是Cortex微处理器软件接口标准 stm32每组gpio有7组端口,分别是2个3 ...
- Java并发编程:线程池的使用(转载)
文章出处:http://www.cnblogs.com/dolphin0520/p/3932921.html Java并发编程:线程池的使用 在前面的文章中,我们使用线程的时候就去创建一个线程,这样实 ...
- FileZilla_server在Windows和Linnx下的部署安装
1. FileZilla官网下载FileZilla Server服务器,目前最新版本为0.9.53. 2. 安装FileZilla服务器.除以下声明的地方外,其它均采用默认模式,如安装路径等. 2.1 ...
- hdu 4135 [a,b]中n互质数个数+容斥
http://acm.hdu.edu.cn/showproblem.php?pid=4135 给定一个数n,求某个区间[a,b]内有多少数与这个数互质. 对于一个给定的区间,我们如果能够求出这个区间内 ...