diff --git a/core/src/main/java/lucee/transformer/bytecode/BytecodeFactory.java b/core/src/main/java/lucee/transformer/bytecode/BytecodeFactory.java index 5b553236e3..2bc941ef36 100644 --- a/core/src/main/java/lucee/transformer/bytecode/BytecodeFactory.java +++ b/core/src/main/java/lucee/transformer/bytecode/BytecodeFactory.java @@ -159,7 +159,7 @@ public LitNumber createLitNumber(Number n) { @Override public LitNumber createLitNumber(Number n, Position start, Position end) { - return new LitNumberImpl(this, n instanceof BigDecimal ? (BigDecimal) n : BigDecimal.valueOf(n.doubleValue()), start, end); + return new LitNumberImpl(this, n, start, end); } @Override diff --git a/core/src/main/java/lucee/transformer/bytecode/literal/LitBooleanImpl.java b/core/src/main/java/lucee/transformer/bytecode/literal/LitBooleanImpl.java index 5e9f2977c9..fcc8903d48 100644 --- a/core/src/main/java/lucee/transformer/bytecode/literal/LitBooleanImpl.java +++ b/core/src/main/java/lucee/transformer/bytecode/literal/LitBooleanImpl.java @@ -23,7 +23,6 @@ import org.objectweb.asm.Type; import org.objectweb.asm.commons.GeneratorAdapter; -import lucee.runtime.engine.ThreadLocalPageContext; import lucee.runtime.op.Caster; import lucee.transformer.Factory; import lucee.transformer.Position; @@ -61,8 +60,7 @@ public LitBooleanImpl(Factory f, boolean b, Position start, Position end) { @Override public Number getNumber(Number defaultValue) { - if (ThreadLocalPageContext.preciseMath(null)) return b ? BigDecimal.ONE : BigDecimal.ZERO; - return Caster.toDouble(b); + return b ? BigDecimal.ONE : BigDecimal.ZERO; } /** diff --git a/core/src/main/java/lucee/transformer/bytecode/literal/LitNumberImpl.java b/core/src/main/java/lucee/transformer/bytecode/literal/LitNumberImpl.java index a18c76c5eb..ec652e0aef 100644 --- a/core/src/main/java/lucee/transformer/bytecode/literal/LitNumberImpl.java +++ b/core/src/main/java/lucee/transformer/bytecode/literal/LitNumberImpl.java @@ -46,18 +46,17 @@ public class LitNumberImpl extends ExpressionBase implements LitNumber, ExprNumb } private String number; - private BigDecimal bd; + private Number nbr; public LitNumberImpl(Factory f, String number, Position start, Position end) { super(f, start, end); this.number = number; } - public LitNumberImpl(Factory f, BigDecimal bd, Position start, Position end) { + public LitNumberImpl(Factory f, Number nbr, Position start, Position end) { super(f, start, end); - this.bd = bd; - this.number = Caster.toString(bd); - + this.nbr = nbr; + this.number = Caster.toString(nbr); } @Override @@ -96,14 +95,13 @@ public Boolean getBoolean(Boolean defaultValue) { } public BigDecimal getBigDecimal() throws CasterException { - if (bd == null) bd = Caster.toBigDecimal(number); - return bd; + if (nbr == null) return Caster.toBigDecimal(number); + return Caster.toBigDecimal(nbr); } @Override public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException { GeneratorAdapter adapter = bc.getAdapter(); - // are we within a method not providing PageContext as first argument? boolean firstIsPC = ASMUtil.isFirstArgumentPageContext(bc); @@ -116,7 +114,8 @@ public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException } return Types.DOUBLE_VALUE; } - Long l = justNumberDigits(number) ? Caster.toLong(number, null) : null; + // we only take length 18 to avoid edge cases + Long l = number.length() < 18 && justNumberDigits(number) ? Caster.toLong(number, null) : null; if (l != null && Caster.toString(l).equals(number)) { if (firstIsPC) adapter.loadArg(0); diff --git a/core/src/main/java/lucee/transformer/bytecode/literal/LitStringImpl.java b/core/src/main/java/lucee/transformer/bytecode/literal/LitStringImpl.java index 6e84ab3a2e..f4433eceb9 100644 --- a/core/src/main/java/lucee/transformer/bytecode/literal/LitStringImpl.java +++ b/core/src/main/java/lucee/transformer/bytecode/literal/LitStringImpl.java @@ -25,7 +25,6 @@ import lucee.commons.lang.ExceptionUtil; import lucee.commons.lang.StringUtil; import lucee.runtime.config.ConfigPro; -import lucee.runtime.engine.ThreadLocalPageContext; import lucee.runtime.op.Caster; import lucee.transformer.Factory; import lucee.transformer.Position; @@ -140,9 +139,7 @@ private static ExprString _toExpr(Factory factory, String str) { @Override public Number getNumber(Number defaultValue) { - Number res; - if (ThreadLocalPageContext.preciseMath(null)) res = Caster.toBigDecimal(str, null); - else res = Caster.toDouble(getString(), null); + Number res = Caster.toBigDecimal(str, null); if (res != null) return res; return defaultValue; } diff --git a/core/src/main/java/lucee/transformer/interpreter/literal/LitBooleanImpl.java b/core/src/main/java/lucee/transformer/interpreter/literal/LitBooleanImpl.java index cb9961f8b0..20682f22a6 100644 --- a/core/src/main/java/lucee/transformer/interpreter/literal/LitBooleanImpl.java +++ b/core/src/main/java/lucee/transformer/interpreter/literal/LitBooleanImpl.java @@ -2,7 +2,6 @@ import java.math.BigDecimal; -import lucee.runtime.engine.ThreadLocalPageContext; import lucee.runtime.op.Caster; import lucee.transformer.Factory; import lucee.transformer.Position; @@ -78,8 +77,7 @@ public boolean getBooleanValue() { @Override public Number getNumber(Number defaultValue) { - if (ThreadLocalPageContext.preciseMath(null)) return b ? BigDecimal.ONE : BigDecimal.ZERO; - return Caster.toDouble(b); + return b ? BigDecimal.ONE : BigDecimal.ZERO; } @Override diff --git a/core/src/main/java/lucee/transformer/interpreter/literal/LitStringImpl.java b/core/src/main/java/lucee/transformer/interpreter/literal/LitStringImpl.java index a5fde2d397..2e7e706468 100644 --- a/core/src/main/java/lucee/transformer/interpreter/literal/LitStringImpl.java +++ b/core/src/main/java/lucee/transformer/interpreter/literal/LitStringImpl.java @@ -1,6 +1,5 @@ package lucee.transformer.interpreter.literal; -import lucee.runtime.engine.ThreadLocalPageContext; import lucee.runtime.op.Caster; import lucee.transformer.Factory; import lucee.transformer.Position; @@ -41,9 +40,7 @@ public String getString() { @Override public Number getNumber(Number defaultValue) { - Number res; - if (ThreadLocalPageContext.preciseMath(null)) res = Caster.toBigDecimal(str, null); - else res = Caster.toDouble(getString(), null); + Number res = Caster.toBigDecimal(str, null); if (res != null) return res; return defaultValue; } diff --git a/loader/build.xml b/loader/build.xml index eb4274faad..06a1175772 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index ea54815c94..37d37b9448 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.2.0.207-SNAPSHOT + 6.2.0.208-SNAPSHOT jar Lucee Loader Build