|
6 | 6 | */
|
7 | 7 | public class Throwables {
|
8 | 8 |
|
9 |
| - public static final String METHOD_SIGNATURE_PATTERN = |
10 |
| - "\\tat " + Throwables.class.getName().replace(".", "\\.") + "\\.createThrowableWithDeepCause\\(" |
11 |
| - + Throwables.class.getSimpleName() + "\\.java:\\d+\\)"; |
12 |
| - public static final String CAUSE_METHOD_SIGNATURE_PATTERN = |
13 |
| - "\\tat " + Throwables.class.getName().replace(".", "\\.") + "\\.createDeepThrowable\\(" |
14 |
| - + Throwables.class.getSimpleName() + "\\.java:\\d+\\)"; |
| 9 | + private static String methodSignaturePatternModulePath() { |
| 10 | + return "\\tat " + Throwables.class.getModule().getName() + "@" |
| 11 | + + Throwables.class.getModule().getDescriptor().version().orElseThrow() + "/" |
| 12 | + + Throwables.class.getName().replace(".", "\\.") + "\\.createThrowableWithDeepCause\\(" |
| 13 | + + Throwables.class.getSimpleName() + "\\.java:\\d+\\)"; |
| 14 | + } |
| 15 | + |
| 16 | + private static String methodSignaturePatternClasspath() { |
| 17 | + return "\\tat " + Throwables.class.getName().replace(".", "\\.") + "\\.createThrowableWithDeepCause\\(" |
| 18 | + + Throwables.class.getSimpleName() + "\\.java:\\d+\\)"; |
| 19 | + } |
| 20 | + |
| 21 | + private static String causeMethodSignaturePatternModulePath() { |
| 22 | + return "\\tat " + Throwables.class.getModule().getName() + "@" |
| 23 | + + Throwables.class.getModule().getDescriptor().version().orElseThrow() + "/" |
| 24 | + + Throwables.class.getName().replace(".", "\\.") + "\\.createDeepThrowable\\(" |
| 25 | + + Throwables.class.getSimpleName() + "\\.java:\\d+\\)"; |
| 26 | + } |
| 27 | + |
| 28 | + private static String causeMethodSignaturePatternClasspath() { |
| 29 | + return "\\tat " + Throwables.class.getName().replace(".", "\\.") + "\\.createDeepThrowable\\(" |
| 30 | + + Throwables.class.getSimpleName() + "\\.java:\\d+\\)"; |
| 31 | + } |
| 32 | + |
| 33 | + public static String METHOD_SIGNATURE_PATTERN = Throwables.class.getModule().isNamed() |
| 34 | + ? methodSignaturePatternModulePath() |
| 35 | + : methodSignaturePatternClasspath(); |
| 36 | + |
| 37 | + public static String CAUSE_METHOD_SIGNATURE_PATTERN = |
| 38 | + Throwables.class.getModule().isNamed() |
| 39 | + ? causeMethodSignaturePatternModulePath() |
| 40 | + : causeMethodSignaturePatternClasspath(); |
15 | 41 |
|
16 | 42 | private Throwables() {}
|
17 | 43 |
|
|
0 commit comments