karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject git commit: [KARAF-3335]make endorsed java.lang.Exception compatible with JDK7 (cherry picked from commit c54c1542cb1f54635d0b17d366233ad468bed2a5)
Date Wed, 29 Oct 2014 03:04:09 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-2.x 74734c059 -> 8eb5d4672


[KARAF-3335]make endorsed java.lang.Exception compatible with JDK7
(cherry picked from commit c54c1542cb1f54635d0b17d366233ad468bed2a5)


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8eb5d467
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8eb5d467
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8eb5d467

Branch: refs/heads/karaf-2.x
Commit: 8eb5d467224c951439b5fdf6272c5e0785510a0b
Parents: 74734c0
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Wed Oct 29 11:01:04 2014 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Wed Oct 29 11:03:39 2014 +0800

----------------------------------------------------------------------
 .../src/main/java/java/lang/Exception.java      | 42 ++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/8eb5d467/exception/src/main/java/java/lang/Exception.java
----------------------------------------------------------------------
diff --git a/exception/src/main/java/java/lang/Exception.java b/exception/src/main/java/java/lang/Exception.java
index 2be5593..05c79ab 100644
--- a/exception/src/main/java/java/lang/Exception.java
+++ b/exception/src/main/java/java/lang/Exception.java
@@ -17,6 +17,8 @@
 
 package java.lang;
 
+import java.lang.reflect.Field;
+
 
 /**
  * {@code Exception} is the superclass of all classes that represent recoverable
@@ -74,6 +76,46 @@ public class Exception extends Throwable {
         super(throwable);
     }
 
+    /**
+     * Constructs a new exception with the specified detail message,
+     * cause, suppression enabled or disabled, and writable stack
+     * trace enabled or disabled.
+     *
+     * @param  message the detail message.
+     * @param cause the cause.  (A {@code null} value is permitted,
+     * and indicates that the cause is nonexistent or unknown.)
+     * @param enableSuppression whether or not suppression is enabled
+     *                          or disabled
+     * @param writableStackTrace whether or not the stack trace should
+     *                           be writable
+     */
+    protected Exception(String message, Throwable cause, boolean enableSuppression, boolean
writableStackTrace) {
+        try {
+            Field field = null;
+            if (writableStackTrace) {
+                fillInStackTrace();
+            } else {
+                field = Throwable.class.getDeclaredField("stackTrace");
+                field.setAccessible(true);
+                field.set(this, null);
+            }
+            field = Throwable.class.getDeclaredField("detailMessage");
+            field.setAccessible(true);
+            field.set(this, message);
+            field = Throwable.class.getDeclaredField("cause");
+            field.setAccessible(true);
+            field.set(this, cause);
+            if (!enableSuppression) {
+                field = Throwable.class.getDeclaredField("suppressedExceptions");
+                field.setAccessible(true);
+                field.set(this, null);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+ 
     public Class[] getClassContext() {
         return classContext;
     }


Mime
View raw message