From ae212aa9cf0c7ed3bf76d85e4f62b328d4378176 Mon Sep 17 00:00:00 2001 From: Shevek Date: Wed, 15 Apr 2015 11:30:38 -0700 Subject: Backport source API to Java 1.5 for compatibility. --- src/main/java/org/anarres/cpp/CppReader.java | 5 ++++- src/main/java/org/anarres/cpp/NumericValue.java | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/anarres/cpp/CppReader.java b/src/main/java/org/anarres/cpp/CppReader.java index 5517f47..4da49a5 100644 --- a/src/main/java/org/anarres/cpp/CppReader.java +++ b/src/main/java/org/anarres/cpp/CppReader.java @@ -111,7 +111,10 @@ public class CppReader extends Reader implements Closeable { } return true; } catch (LexerException e) { - throw new IOException(String.valueOf(e), e); + // new IOException(String, Throwable) is since 1.6 + IOException _e = new IOException(String.valueOf(e)); + _e.initCause(e); + throw _e; } } diff --git a/src/main/java/org/anarres/cpp/NumericValue.java b/src/main/java/org/anarres/cpp/NumericValue.java index e4235d3..7feb758 100644 --- a/src/main/java/org/anarres/cpp/NumericValue.java +++ b/src/main/java/org/anarres/cpp/NumericValue.java @@ -135,7 +135,8 @@ public class NumericValue extends Number { @Override public int intValue() { - int v = integer.isEmpty() ? 0 : Integer.parseInt(integer, base); + // String.isEmpty() is since 1.6 + int v = integer.length() == 0 ? 0 : Integer.parseInt(integer, base); if (expbase == 2) v = v << exponentValue(); else if (expbase != 0) @@ -145,7 +146,8 @@ public class NumericValue extends Number { @Override public long longValue() { - long v = integer.isEmpty() ? 0 : Long.parseLong(integer, base); + // String.isEmpty() is since 1.6 + long v = integer.length() == 0 ? 0 : Long.parseLong(integer, base); if (expbase == 2) v = v << exponentValue(); else if (expbase != 0) -- cgit v1.2.3