From c6fe5e0ef2f60c79090a20d2e889aa9de912a41c Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 26 Sep 2014 20:58:43 -0700 Subject: [PATCH] Fix review comments --- override.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/override.js b/override.js index 6b8b5edc..0715d451 100644 --- a/override.js +++ b/override.js @@ -74,8 +74,10 @@ Override["java/io/ByteArrayInputStream.read.([BII)I"] = function(ctx, stack) { if (!b) { ctx.raiseExceptionAndYield("java/lang/NullPointerException"); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { + } + + if ((off < 0) || (off > b.length) || (len < 0) || + ((off + len) > b.length)) { ctx.raiseExceptionAndYield("java/lang/IndexOutOfBoundsException"); } @@ -86,7 +88,7 @@ Override["java/io/ByteArrayInputStream.read.([BII)I"] = function(ctx, stack) { if (_this.pos + len > _this.count) { len = _this.count - _this.pos; } - if (len <= 0) { + if (len === 0) { stack.push(0); return; } @@ -98,9 +100,7 @@ Override["java/io/ByteArrayInputStream.read.([BII)I"] = function(ctx, stack) { } Override["java/io/ByteArrayInputStream.skip.(J)J"] = function(ctx, stack) { - var nLong = stack.pop2(), _this = stack.pop(); - - var n = nLong.toNumber(); + var n = stack.pop2().toNumber(), _this = stack.pop(); if (_this.pos + n > _this.count) { n = _this.count - _this.pos; @@ -113,7 +113,7 @@ Override["java/io/ByteArrayInputStream.skip.(J)J"] = function(ctx, stack) { _this.pos += n; - stack.push2(nLong); + stack.push2(Long.fromNumber(n)); } Override["java/io/ByteArrayInputStream.available.()I"] = function(ctx, stack) {