aboutsummaryrefslogtreecommitdiffstats
path: root/lib/jinterface
diff options
context:
space:
mode:
Diffstat (limited to 'lib/jinterface')
-rw-r--r--lib/jinterface/doc/src/notes.xml21
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/Makefile2
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangString.java19
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpMbox.java4
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java4
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java57
-rw-r--r--lib/jinterface/test/nc_SUITE.erl7
-rw-r--r--lib/jinterface/test/nc_SUITE_data/echo_server.java6
-rw-r--r--lib/jinterface/vsn.mk2
9 files changed, 89 insertions, 33 deletions
diff --git a/lib/jinterface/doc/src/notes.xml b/lib/jinterface/doc/src/notes.xml
index 11fcc5f387..bf94077114 100644
--- a/lib/jinterface/doc/src/notes.xml
+++ b/lib/jinterface/doc/src/notes.xml
@@ -30,6 +30,27 @@
</header>
<p>This document describes the changes made to the Jinterface application.</p>
+<section><title>Jinterface 1.5.5</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>
+ JInterface: improve OtpOutputStream buffer allocation</p>
+ <p>
+ Previously, the buffer was increased linearly by 2048
+ bytes. I now propose to use an exponential increase
+ function (similar to Javas ArrayList, e.g. always at
+ least +50%). This significantly increases performance of
+ e.g. doRPC for large parameters. (Thanks to Nico Kruber)</p>
+ <p>
+ Own Id: OTP-9806</p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Jinterface 1.5.4</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/Makefile b/lib/jinterface/java_src/com/ericsson/otp/erlang/Makefile
index e772a2b0a5..365798e68a 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/Makefile
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/Makefile
@@ -3,7 +3,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2000-2009. All Rights Reserved.
+# Copyright Ericsson AB 2000-2011. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangString.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangString.java
index 23734bf83b..be8b7c5c12 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangString.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangString.java
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2000-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2000-2011. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -154,13 +154,16 @@ public class OtpErlangString extends OtpErlangObject implements Serializable,
* Unicode code points
*/
- public static int[] stringToCodePoints(final String s) {
- final int m = s.codePointCount(0, s.length());
- final int [] codePoints = new int[m];
- for (int i = 0, j = 0; j < m; i = s.offsetByCodePoints(i, 1), j++) {
- codePoints[j] = s.codePointAt(i);
- }
- return codePoints;
+ public static int[] stringToCodePoints(final String s) {
+ final int m = s.codePointCount(0, s.length());
+ final int[] codePoints = new int[m];
+ int j = 0;
+ for (int offset = 0; offset < s.length();) {
+ final int codepoint = s.codePointAt(offset);
+ codePoints[j++] = codepoint;
+ offset += Character.charCount(codepoint);
+ }
+ return codePoints;
}
/**
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpMbox.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpMbox.java
index 71a419497a..b0b64e6953 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpMbox.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpMbox.java
@@ -31,7 +31,7 @@ package com.ericsson.otp.erlang;
* the recipient of the message. When sending messages to other mailboxes, the
* recipient can only respond if the sender includes the pid as part of the
* message contents. The sender can determine his own pid by calling
- * {@link #self self()}.
+ * {@link #self() self()}.
* </p>
*
* <p>
@@ -141,7 +141,7 @@ public class OtpMbox {
* Get the registered name of this mailbox.
*
* @return the registered name of this mailbox, or null if the mailbox had
- * no registerd name.
+ * no registered name.
*/
public String getName() {
return name;
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java
index d499fae3fb..be7c8e5b1a 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpNode.java
@@ -182,7 +182,7 @@ public class OtpNode extends OtpLocalNode {
* Create an unnamed {@link OtpMbox mailbox} that can be used to send and
* receive messages with other, similar mailboxes and with Erlang processes.
* Messages can be sent to this mailbox by using its associated
- * {@link OtpMbox#self pid}.
+ * {@link OtpMbox#self() pid}.
*
* @return a mailbox.
*/
@@ -248,7 +248,7 @@ public class OtpNode extends OtpLocalNode {
* Create an named mailbox that can be used to send and receive messages
* with other, similar mailboxes and with Erlang processes. Messages can be
* sent to this mailbox by using its registered name or the associated
- * {@link OtpMbox#self pid}.
+ * {@link OtpMbox#self() pid}.
*
* @param name
* a name to register for this mailbox. The name must be unique
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java
index 181350100f..22ebb4688a 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpOutputStream.java
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2000-2009. All Rights Reserved.
+ * Copyright Ericsson AB 2000-2011. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -25,6 +25,7 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
+import java.util.Arrays;
/**
* Provides a stream for encoding Erlang terms to external format, for
@@ -39,7 +40,7 @@ public class OtpOutputStream extends ByteArrayOutputStream {
/** The default initial size of the stream. * */
public static final int defaultInitialSize = 2048;
- /** The default increment used when growing the stream. * */
+ /** The default increment used when growing the stream (increment at least this much). * */
public static final int defaultIncrement = 2048;
// static formats, used to encode floats and doubles
@@ -95,6 +96,41 @@ public class OtpOutputStream extends ByteArrayOutputStream {
}
/**
+ * Trims the capacity of this <tt>OtpOutputStream</tt> instance to be the
+ * buffer's current size. An application can use this operation to minimize
+ * the storage of an <tt>OtpOutputStream</tt> instance.
+ */
+ public void trimToSize() {
+ if (super.count < super.buf.length) {
+ final byte[] tmp = new byte[super.count];
+ System.arraycopy(super.buf, 0, tmp, 0, super.count);
+ super.buf = tmp;
+ }
+ }
+
+ /**
+ * Increases the capacity of this <tt>OtpOutputStream</tt> instance, if
+ * necessary, to ensure that it can hold at least the number of elements
+ * specified by the minimum capacity argument.
+ *
+ * @param minCapacity the desired minimum capacity
+ */
+ public void ensureCapacity(int minCapacity) {
+ int oldCapacity = super.buf.length;
+ if (minCapacity > oldCapacity) {
+ int newCapacity = (oldCapacity * 3)/2 + 1;
+ if (newCapacity < oldCapacity + defaultIncrement)
+ newCapacity = oldCapacity + defaultIncrement;
+ if (newCapacity < minCapacity)
+ newCapacity = minCapacity;
+ // minCapacity is usually close to size, so this is a win:
+ final byte[] tmp = new byte[newCapacity];
+ System.arraycopy(super.buf, 0, tmp, 0, super.count);
+ super.buf = tmp;
+ }
+ }
+
+ /**
* Write one byte to the stream.
*
* @param b
@@ -102,13 +138,7 @@ public class OtpOutputStream extends ByteArrayOutputStream {
*
*/
public void write(final byte b) {
- if (super.count >= super.buf.length) {
- // System.err.println("Expanding buffer from " + this.buf.length
- // + " to " + (this.buf.length+defaultIncrement));
- final byte[] tmp = new byte[super.buf.length + defaultIncrement];
- System.arraycopy(super.buf, 0, tmp, 0, super.count);
- super.buf = tmp;
- }
+ ensureCapacity(super.count + 1);
super.buf[super.count++] = b;
}
@@ -122,14 +152,7 @@ public class OtpOutputStream extends ByteArrayOutputStream {
@Override
public void write(final byte[] buf) {
- if (super.count + buf.length > super.buf.length) {
- // System.err.println("Expanding buffer from " + super.buf.length
- // + " to " + (buf.length + super.buf.lengt + defaultIncrement));
- final byte[] tmp = new byte[super.buf.length + buf.length
- + defaultIncrement];
- System.arraycopy(super.buf, 0, tmp, 0, super.count);
- super.buf = tmp;
- }
+ ensureCapacity(super.count + buf.length);
System.arraycopy(buf, 0, super.buf, super.count, buf.length);
super.count += buf.length;
}
diff --git a/lib/jinterface/test/nc_SUITE.erl b/lib/jinterface/test/nc_SUITE.erl
index da54f5bf51..9c88400c2a 100644
--- a/lib/jinterface/test/nc_SUITE.erl
+++ b/lib/jinterface/test/nc_SUITE.erl
@@ -296,7 +296,8 @@ lists_roundtrip_2(Config) when is_list(Config) ->
{[z,23|24],tail3},
{[z|25],tail3},
{"abc123",sub3atom},
- {"abc",sub3atom}
+ {"abc",sub3atom},
+ {"abcdefg",codepointBug}
],
Trans =
fun ([_|T], tail) ->
@@ -308,7 +309,9 @@ lists_roundtrip_2(Config) when is_list(Config) ->
(L, tail3) when is_list(L) ->
null;
([_,_,_|L], sub3atom) ->
- list_to_atom(L)
+ list_to_atom(L);
+ (L, codepointBug) ->
+ L
end,
OutTrans =
fun ({L,Twist}) ->
diff --git a/lib/jinterface/test/nc_SUITE_data/echo_server.java b/lib/jinterface/test/nc_SUITE_data/echo_server.java
index 0550e4beb1..5ecb5b72a7 100644
--- a/lib/jinterface/test/nc_SUITE_data/echo_server.java
+++ b/lib/jinterface/test/nc_SUITE_data/echo_server.java
@@ -202,6 +202,12 @@ public class echo_server {
final OtpErlangAtom o = new OtpErlangAtom(s.stringValue()
.substring(3));
return o;
+ } else if (atomValue.equals("codepointBug")
+ && i instanceof OtpErlangString) {
+ final OtpErlangString s = (OtpErlangString) i;
+ final String ss = s.stringValue().substring(3, 6);
+ final int[] cps = OtpErlangString.stringToCodePoints(ss);
+ return s;
} else if (atomValue.equals("utf8")) {
if (i instanceof OtpErlangString) {
final OtpErlangString s = (OtpErlangString) i;
diff --git a/lib/jinterface/vsn.mk b/lib/jinterface/vsn.mk
index 9d75a653e3..9d8229e9fa 100644
--- a/lib/jinterface/vsn.mk
+++ b/lib/jinterface/vsn.mk
@@ -1 +1 @@
-JINTERFACE_VSN = 1.5.4
+JINTERFACE_VSN = 1.5.5