This commit is contained in:
Tim Bell 2008-08-25 23:37:31 -07:00
commit 33a47ac00d
51 changed files with 1270 additions and 2786 deletions

View file

@ -451,7 +451,7 @@ vpath %.$(OBJECT_SUFFIX) $(OBJDIR)
# namely jni.h, jvm.h, and jni_utils.h, plus their platform-specific # namely jni.h, jvm.h, and jni_utils.h, plus their platform-specific
# relatives. # relatives.
# #
VPATH.h = $(PLATFORM_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/include$(CLASSPATH_SEPARATOR)$(PLATFORM_SRC)/javavm/include VPATH.h = $(PLATFORM_SRC)/javavm/export$(CLASSPATH_SEPARATOR)$(SHARE_SRC)/javavm/export
vpath %.h $(VPATH.h) vpath %.h $(VPATH.h)
# #

View file

@ -57,7 +57,7 @@ SUNWprivate_1.1 {
Java_java_net_Inet6AddressImpl_isReachable0; Java_java_net_Inet6AddressImpl_isReachable0;
Java_java_net_NetworkInterface_init; Java_java_net_NetworkInterface_init;
Java_java_net_NetworkInterface_getByName0; Java_java_net_NetworkInterface_getByName0;
Java_java_net_NetworkInterface_getByIndex; Java_java_net_NetworkInterface_getByIndex0;
Java_java_net_NetworkInterface_getByInetAddress0; Java_java_net_NetworkInterface_getByInetAddress0;
Java_java_net_NetworkInterface_getAll; Java_java_net_NetworkInterface_getAll;
Java_java_net_NetworkInterface_isUp0; Java_java_net_NetworkInterface_isUp0;

View file

@ -1,5 +1,5 @@
# #
# Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved. # Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -52,12 +52,6 @@ FILES_c = \
check_code.c \ check_code.c \
check_format.c check_format.c
#
# libverify.so needs these 2 header files (opcodes.h opcodes.length)
# from the VM.
#
CPPFLAGS += -I$(SHARE_SRC)/javavm/include
# #
# Targets. # Targets.
# #

View file

@ -145,7 +145,6 @@ Notes on using CND (C/C++ pack) with this project and NetBeans.
(a somewhat complete list of awt and 2d native directories on windows): (a somewhat complete list of awt and 2d native directories on windows):
../../src/share/javavm/export; ../../src/share/javavm/export;
../../src/share/javavm/include;
../../src/share/native/common; ../../src/share/native/common;
../../src/share/native/sun/awt/debug; ../../src/share/native/sun/awt/debug;
../../src/share/native/sun/awt/image/cvutils; ../../src/share/native/sun/awt/image/cvutils;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,7 +37,6 @@
#include "bool.h" #include "bool.h"
#include "utf.h" #include "utf.h"
#include "tree.h" #include "tree.h"
#include "sys_api.h"
extern bool_t verify_class_codes(ClassClass *cb); extern bool_t verify_class_codes(ClassClass *cb);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -41,7 +41,6 @@
#include "ArrayReferenceImpl.h" #include "ArrayReferenceImpl.h"
#include "EventRequestImpl.h" #include "EventRequestImpl.h"
#include "StackFrameImpl.h" #include "StackFrameImpl.h"
#include "typedefs.h"
static void **l1Array; static void **l1Array;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,7 +48,6 @@
#include "util.h" #include "util.h"
#include "proc_md.h" #include "proc_md.h"
#include "typedefs.h"
/* Maximim length of a message */ /* Maximim length of a message */
#define MAX_MESSAGE_LEN MAXPATHLEN*2+512 #define MAX_MESSAGE_LEN MAXPATHLEN*2+512

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,6 @@
#include "bag.h" #include "bag.h"
#include "commonRef.h" #include "commonRef.h"
#include "FrameID.h" #include "FrameID.h"
#include "typedefs.h"
#define INITIAL_REF_ALLOC 50 #define INITIAL_REF_ALLOC 50
#define SMALLEST(a, b) ((a) < (b)) ? (a) : (b) #define SMALLEST(a, b) ((a) < (b)) ? (a) : (b)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,8 +26,6 @@
#ifndef JDWP_OUTSTREAM_H #ifndef JDWP_OUTSTREAM_H
#define JDWP_OUTSTREAM_H #define JDWP_OUTSTREAM_H
#include "typedefs.h"
#include "transport.h" #include "transport.h"
#include "FrameID.h" #include "FrameID.h"

View file

@ -203,11 +203,17 @@ public final class NetworkInterface {
} }
/** /**
* Get the index of this network interface. * Returns the index of this network interface. The index is an integer greater
* or equal to zero, or {@code -1} for unknown. This is a system specific value
* and interfaces with the same name can have different indexes on different
* machines.
* *
* @return the index of this network interface * @return the index of this network interface or {@code -1} if the index is
* unknown
* @see #getByIndex(int)
* @since 1.7
*/ */
int getIndex() { public int getIndex() {
return index; return index;
} }
@ -249,11 +255,18 @@ public final class NetworkInterface {
* Get a network interface given its index. * Get a network interface given its index.
* *
* @param index an integer, the index of the interface * @param index an integer, the index of the interface
* @return the NetworkInterface obtained from its index * @return the NetworkInterface obtained from its index, or {@code null} if
* @exception SocketException if an I/O error occurs. * there is no interface with such an index on the system
* @throws SocketException if an I/O error occurs.
* @throws IllegalArgumentException if index has a negative value
* @see #getIndex()
* @since 1.7
*/ */
native static NetworkInterface getByIndex(int index) public static NetworkInterface getByIndex(int index) throws SocketException {
throws SocketException; if (index < 0)
throw new IllegalArgumentException("Interface index can't be negative");
return getByIndex0(index);
}
/** /**
* Convenience method to search for a network interface that * Convenience method to search for a network interface that
@ -325,6 +338,9 @@ public final class NetworkInterface {
private native static NetworkInterface getByName0(String name) private native static NetworkInterface getByName0(String name)
throws SocketException; throws SocketException;
private native static NetworkInterface getByIndex0(int index)
throws SocketException;
private native static NetworkInterface getByInetAddress0(InetAddress addr) private native static NetworkInterface getByInetAddress0(InetAddress addr)
throws SocketException; throws SocketException;

View file

@ -142,14 +142,18 @@ class ServerSocket implements java.io.Closeable {
* as its argument to ensure the operation is allowed. * as its argument to ensure the operation is allowed.
* This could result in a SecurityException. * This could result in a SecurityException.
* *
* <P>The <code>backlog</code> argument must be a positive * The <code>backlog</code> argument is the requested maximum number of
* value greater than 0. If the value passed is equal or less * pending connections on the socket. Its exact semantics are implementation
* than 0, then the default value will be assumed. * specific. In particular, an implementation may impose a maximum length
* or may choose to ignore the parameter altogther. The value provided
* should be greater than <code>0</code>. If it is less than or equal to
* <code>0</code>, then an implementation specific default will be used.
* <P> * <P>
* *
* @param port the port number, or <code>0</code> to use a port * @param port the port number, or <code>0</code> to use a port
* number that is automatically allocated. * number that is automatically allocated.
* @param backlog the maximum length of the queue. * @param backlog requested maximum length of the queue of incoming
* connections.
* *
* @exception IOException if an I/O error occurs when opening the socket. * @exception IOException if an I/O error occurs when opening the socket.
* @exception SecurityException * @exception SecurityException
@ -187,13 +191,17 @@ class ServerSocket implements java.io.Closeable {
* as its argument to ensure the operation is allowed. * as its argument to ensure the operation is allowed.
* This could result in a SecurityException. * This could result in a SecurityException.
* *
* <P>The <code>backlog</code> argument must be a positive * The <code>backlog</code> argument is the requested maximum number of
* value greater than 0. If the value passed is equal or less * pending connections on the socket. Its exact semantics are implementation
* than 0, then the default value will be assumed. * specific. In particular, an implementation may impose a maximum length
* or may choose to ignore the parameter altogther. The value provided
* should be greater than <code>0</code>. If it is less than or equal to
* <code>0</code>, then an implementation specific default will be used.
* <P> * <P>
* @param port the port number, or <code>0</code> to use a port * @param port the port number, or <code>0</code> to use a port
* number that is automatically allocated. * number that is automatically allocated.
* @param backlog the listen backlog * @param backlog requested maximum length of the queue of incoming
* connections.
* @param bindAddr the local InetAddress the server will bind to * @param bindAddr the local InetAddress the server will bind to
* *
* @throws SecurityException if a security manager exists and * @throws SecurityException if a security manager exists and
@ -321,11 +329,15 @@ class ServerSocket implements java.io.Closeable {
* If the address is <code>null</code>, then the system will pick up * If the address is <code>null</code>, then the system will pick up
* an ephemeral port and a valid local address to bind the socket. * an ephemeral port and a valid local address to bind the socket.
* <P> * <P>
* The <code>backlog</code> argument must be a positive * The <code>backlog</code> argument is the requested maximum number of
* value greater than 0. If the value passed is equal or less * pending connections on the socket. Its exact semantics are implementation
* than 0, then the default value will be assumed. * specific. In particular, an implementation may impose a maximum length
* or may choose to ignore the parameter altogther. The value provided
* should be greater than <code>0</code>. If it is less than or equal to
* <code>0</code>, then an implementation specific default will be used.
* @param endpoint The IP address & port number to bind to. * @param endpoint The IP address & port number to bind to.
* @param backlog The listen backlog length. * @param backlog requested maximum length of the queue of
* incoming connections.
* @throws IOException if the bind operation fails, or if the socket * @throws IOException if the bind operation fails, or if the socket
* is already bound. * is already bound.
* @throws SecurityException if a <code>SecurityManager</code> is present and * @throws SecurityException if a <code>SecurityManager</code> is present and

View file

@ -432,4 +432,11 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
Object writeReplace() { Object writeReplace() {
return new SerializationProxy<E>(this); return new SerializationProxy<E>(this);
} }
// readObject method for the serialization proxy pattern
// See Effective Java, Second Ed., Item 78.
private void readObject(java.io.ObjectInputStream stream)
throws java.io.InvalidObjectException {
throw new java.io.InvalidObjectException("Proxy required");
}
} }

View file

@ -108,9 +108,12 @@ public abstract class SSLServerSocket extends ServerSocket
* <P> * <P>
* A port number of <code>0</code> creates a socket on any free port. * A port number of <code>0</code> creates a socket on any free port.
* <P> * <P>
* The <code>backlog</code> argument must be a positive * The <code>backlog</code> argument is the requested maximum number of
* value greater than 0. If the value passed if equal or less * pending connections on the socket. Its exact semantics are implementation
* than 0, then the default value will be assumed. * specific. In particular, an implementation may impose a maximum length
* or may choose to ignore the parameter altogther. The value provided
* should be greater than <code>0</code>. If it is less than or equal to
* <code>0</code>, then an implementation specific default will be used.
* <P> * <P>
* If there is a security manager, its <code>checkListen</code> * If there is a security manager, its <code>checkListen</code>
* method is called with the <code>port</code> argument as its * method is called with the <code>port</code> argument as its
@ -118,8 +121,8 @@ public abstract class SSLServerSocket extends ServerSocket
* in a SecurityException. * in a SecurityException.
* *
* @param port the port on which to listen * @param port the port on which to listen
* @param backlog how many connections may be pending before * @param backlog requested maximum length of the queue of incoming
* the system should start rejecting new requests * connections.
* @throws IOException if an I/O error occurs when creating the socket * @throws IOException if an I/O error occurs when creating the socket
* @throws SecurityException if a security manager exists and its * @throws SecurityException if a security manager exists and its
* <code>checkListen</code> method doesn't allow the operation. * <code>checkListen</code> method doesn't allow the operation.
@ -150,16 +153,19 @@ public abstract class SSLServerSocket extends ServerSocket
* <P> * <P>
* A port number of <code>0</code> creates a socket on any free port. * A port number of <code>0</code> creates a socket on any free port.
* <P> * <P>
* <P>The <code>backlog</code> argument must be a positive * The <code>backlog</code> argument is the requested maximum number of
* value greater than 0. If the value passed if equal or less * pending connections on the socket. Its exact semantics are implementation
* than 0, then the default value will be assumed. * specific. In particular, an implementation may impose a maximum length
* or may choose to ignore the parameter altogther. The value provided
* should be greater than <code>0</code>. If it is less than or equal to
* <code>0</code>, then an implementation specific default will be used.
* <P> * <P>
* If <i>address</i> is null, it will default accepting connections * If <i>address</i> is null, it will default accepting connections
* on any/all local addresses. * on any/all local addresses.
* *
* @param port the port on which to listen * @param port the port on which to listen
* @param backlog how many connections may be pending before * @param backlog requested maximum length of the queue of incoming
* the system should start rejecting new requests * connections.
* @param address the address of the network interface through * @param address the address of the network interface through
* which connections will be accepted * which connections will be accepted
* @throws IOException if an I/O error occurs when creating the socket * @throws IOException if an I/O error occurs when creating the socket

View file

@ -25,34 +25,36 @@
package sun.nio.cs; package sun.nio.cs;
import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.CharBuffer; import java.nio.CharBuffer;
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult; import java.nio.charset.CoderResult;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.MalformedInputException;
import java.nio.charset.UnmappableCharacterException;
/* Legal UTF-8 Byte Sequences
/* *
* # Bits Bit pattern * # Code Points Bits Bit/Byte pattern
* 1 7 0xxxxxxx * 1 7 0xxxxxxx
* 2 11 110xxxxx 10xxxxxx * U+0000..U+007F 00..7F
* 3 16 1110xxxx 10xxxxxx 10xxxxxx *
* 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx * 2 11 110xxxxx 10xxxxxx
* 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx * U+0080..U+07FF C2..DF 80..BF
* 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx *
* 3 16 1110xxxx 10xxxxxx 10xxxxxx
* U+0800..U+0FFF E0 A0..BF 80..BF
* U+1000..U+FFFF E1..EF 80..BF 80..BF
*
* 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
* U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
* U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
* U+100000..U10FFFF F4 80..8F 80..BF 80..BF
* *
* UCS-2 uses 1-3, UTF-16 uses 1-4, UCS-4 uses 1-6
*/ */
class UTF_8 extends Unicode class UTF_8 extends Unicode
{ {
public UTF_8() { public UTF_8() {
super("UTF-8", StandardCharsets.aliases_UTF_8); super("UTF-8", StandardCharsets.aliases_UTF_8);
} }
@ -69,304 +71,250 @@ class UTF_8 extends Unicode
return new Encoder(this); return new Encoder(this);
} }
static final void updatePositions(Buffer src, int sp,
Buffer dst, int dp) {
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
}
private static class Decoder extends CharsetDecoder { private static class Decoder extends CharsetDecoder {
private Decoder(Charset cs) { private Decoder(Charset cs) {
super(cs, 1.0f, 1.0f); super(cs, 1.0f, 1.0f);
} }
private boolean isContinuation(int b) { private static boolean isNotContinuation(int b) {
return ((b & 0xc0) == 0x80); return (b & 0xc0) != 0x80;
} }
private final Surrogate.Generator sgg = new Surrogate.Generator(); // [C2..DF] [80..BF]
private static boolean isMalformed2(int b1, int b2) {
return (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
}
// [E0] [A0..BF] [80..BF]
// [E1..EF] [80..BF] [80..BF]
private static boolean isMalformed3(int b1, int b2, int b3) {
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
(b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
}
// [F0] [90..BF] [80..BF] [80..BF]
// [F1..F3] [80..BF] [80..BF] [80..BF]
// [F4] [80..8F] [80..BF] [80..BF]
// only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
// will be checked by Surrogate.neededFor(uc)
private static boolean isMalformed4(int b2, int b3, int b4) {
return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
(b4 & 0xc0) != 0x80;
}
private static CoderResult lookupN(ByteBuffer src, int n)
{
for (int i = 1; i < n; i++) {
if (isNotContinuation(src.get()))
return CoderResult.malformedForLength(i);
}
return CoderResult.malformedForLength(n);
}
private static CoderResult malformedN(ByteBuffer src, int nb) {
switch (nb) {
case 1:
int b1 = src.get();
if ((b1 >> 2) == -2) {
// 5 bytes 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
if (src.remaining() < 4)
return CoderResult.UNDERFLOW;
return lookupN(src, 5);
}
if ((b1 >> 1) == -2) {
// 6 bytes 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
if (src.remaining() < 5)
return CoderResult.UNDERFLOW;
return lookupN(src, 6);
}
return CoderResult.malformedForLength(1);
case 2: // always 1
return CoderResult.malformedForLength(1);
case 3:
b1 = src.get();
int b2 = src.get(); // no need to lookup b3
return CoderResult.malformedForLength(
((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
isNotContinuation(b2))?1:2);
case 4: // we don't care the speed here
b1 = src.get() & 0xff;
b2 = src.get() & 0xff;
if (b1 > 0xf4 ||
(b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
(b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
isNotContinuation(b2))
return CoderResult.malformedForLength(1);
if (isNotContinuation(src.get()))
return CoderResult.malformedForLength(2);
return CoderResult.malformedForLength(3);
default:
assert false;
return null;
}
}
private static CoderResult malformed(ByteBuffer src, int sp,
CharBuffer dst, int dp,
int nb)
{
src.position(sp - src.arrayOffset());
CoderResult cr = malformedN(src, nb);
updatePositions(src, sp, dst, dp);
return cr;
}
private static CoderResult malformed(ByteBuffer src,
int mark, int nb)
{
src.position(mark);
CoderResult cr = malformedN(src, nb);
src.position(mark);
return cr;
}
private static CoderResult xflow(Buffer src, int sp, int sl,
Buffer dst, int dp, int nb) {
updatePositions(src, sp, dst, dp);
return (nb == 0 || sl - sp < nb)
?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
}
private static CoderResult xflow(Buffer src, int mark, int nb) {
CoderResult cr = (nb == 0 || src.remaining() < (nb - 1))
?CoderResult.UNDERFLOW:CoderResult.OVERFLOW;
src.position(mark);
return cr;
}
private CoderResult decodeArrayLoop(ByteBuffer src, private CoderResult decodeArrayLoop(ByteBuffer src,
CharBuffer dst) CharBuffer dst)
{ {
// This method is optimized for ASCII input.
byte[] sa = src.array(); byte[] sa = src.array();
int sp = src.arrayOffset() + src.position(); int sp = src.arrayOffset() + src.position();
int sl = src.arrayOffset() + src.limit(); int sl = src.arrayOffset() + src.limit();
assert (sp <= sl);
sp = (sp <= sl ? sp : sl);
char[] da = dst.array(); char[] da = dst.array();
int dp = dst.arrayOffset() + dst.position(); int dp = dst.arrayOffset() + dst.position();
int dl = dst.arrayOffset() + dst.limit(); int dl = dst.arrayOffset() + dst.limit();
assert (dp <= dl); int dlASCII = dp + Math.min(sl - sp, dl - dp);
dp = (dp <= dl ? dp : dl);
// ASCII only loop
while (dp < dlASCII && sa[sp] >= 0)
da[dp++] = (char)sa[sp++];
try {
while (sp < sl) { while (sp < sl) {
int b1 = sa[sp]; int b1 = sa[sp];
int b2, b3; if (b1 >= 0) {
switch ((b1 >> 4) & 0x0f) {
case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7:
// 1 byte, 7 bits: 0xxxxxxx // 1 byte, 7 bits: 0xxxxxxx
if (dl - dp < 1) if (dp >= dl)
return CoderResult.OVERFLOW; return xflow(src, sp, sl, dst, dp, 1);
da[dp++] = (char)(b1 & 0x7f); da[dp++] = (char)b1;
sp++; sp++;
continue; } else if ((b1 >> 5) == -2) {
case 12: case 13:
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
if (sl - sp < 2) if (sl - sp < 2 || dp >= dl)
return CoderResult.UNDERFLOW; return xflow(src, sp, sl, dst, dp, 2);
if (dl - dp < 1) int b2 = sa[sp + 1];
return CoderResult.OVERFLOW; if (isMalformed2(b1, b2))
if (!isContinuation(b2 = sa[sp + 1])) return malformed(src, sp, dst, dp, 2);
return CoderResult.malformedForLength(1); da[dp++] = (char) (((b1 << 6) ^ b2) ^ 0x0f80);
da[dp++] = ((char)(((b1 & 0x1f) << 6) |
((b2 & 0x3f) << 0)));
sp += 2; sp += 2;
continue; } else if ((b1 >> 4) == -2) {
case 14:
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
if (sl - sp < 3) if (sl - sp < 3 || dp >= dl)
return CoderResult.UNDERFLOW; return xflow(src, sp, sl, dst, dp, 3);
if (dl - dp < 1) int b2 = sa[sp + 1];
return CoderResult.OVERFLOW; int b3 = sa[sp + 2];
if (!isContinuation(b2 = sa[sp + 1])) if (isMalformed3(b1, b2, b3))
return CoderResult.malformedForLength(1); return malformed(src, sp, dst, dp, 3);
if (!isContinuation(b3 = sa[sp + 2])) da[dp++] = (char) (((b1 << 12) ^ (b2 << 6) ^ b3) ^ 0x1f80);
return CoderResult.malformedForLength(2);
da[dp++] = ((char)(((b1 & 0x0f) << 12) |
((b2 & 0x3f) << 06) |
((b3 & 0x3f) << 0)));
sp += 3; sp += 3;
continue; } else if ((b1 >> 3) == -2) {
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
case 15: if (sl - sp < 4 || dl - dp < 2)
// 4, 5, or 6 bytes return xflow(src, sp, sl, dst, dp, 4);
int b2 = sa[sp + 1];
int b4, b5, b6, uc, n; int b3 = sa[sp + 2];
switch (b1 & 0x0f) { int b4 = sa[sp + 3];
int uc = ((b1 & 0x07) << 18) |
case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7:
// 4 bytes, 21 bits
if (sl - sp < 4)
return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = sa[sp + 1]))
return CoderResult.malformedForLength(1);
if (!isContinuation(b3 = sa[sp + 2]))
return CoderResult.malformedForLength(2);
if (!isContinuation(b4 = sa[sp + 3]))
return CoderResult.malformedForLength(3);
uc = (((b1 & 0x07) << 18) |
((b2 & 0x3f) << 12) | ((b2 & 0x3f) << 12) |
((b3 & 0x3f) << 06) | ((b3 & 0x3f) << 06) |
((b4 & 0x3f) << 00)); (b4 & 0x3f);
n = 4; if (isMalformed4(b2, b3, b4) ||
break; !Surrogate.neededFor(uc)) {
return malformed(src, sp, dst, dp, 4);
case 8: case 9: case 10: case 11:
// 5 bytes, 26 bits
if (sl - sp < 5)
return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = sa[sp + 1]))
return CoderResult.malformedForLength(1);
if (!isContinuation(b3 = sa[sp + 2]))
return CoderResult.malformedForLength(2);
if (!isContinuation(b4 = sa[sp + 3]))
return CoderResult.malformedForLength(3);
if (!isContinuation(b5 = sa[sp + 4]))
return CoderResult.malformedForLength(4);
uc = (((b1 & 0x03) << 24) |
((b2 & 0x3f) << 18) |
((b3 & 0x3f) << 12) |
((b4 & 0x3f) << 06) |
((b5 & 0x3f) << 00));
n = 5;
break;
case 12: case 13:
// 6 bytes, 31 bits
if (sl - sp < 6)
return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = sa[sp + 1]))
return CoderResult.malformedForLength(1);
if (!isContinuation(b3 = sa[sp + 2]))
return CoderResult.malformedForLength(2);
if (!isContinuation(b4 = sa[sp + 3]))
return CoderResult.malformedForLength(3);
if (!isContinuation(b5 = sa[sp + 4]))
return CoderResult.malformedForLength(4);
if (!isContinuation(b6 = sa[sp + 5]))
return CoderResult.malformedForLength(5);
uc = (((b1 & 0x01) << 30) |
((b2 & 0x3f) << 24) |
((b3 & 0x3f) << 18) |
((b4 & 0x3f) << 12) |
((b5 & 0x3f) << 06) |
((b6 & 0x3f)));
n = 6;
break;
default:
return CoderResult.malformedForLength(1);
} }
da[dp++] = Surrogate.high(uc);
int gn = sgg.generate(uc, n, da, dp, dl); da[dp++] = Surrogate.low(uc);
if (gn < 0) sp += 4;
return sgg.error(); } else
dp += gn; return malformed(src, sp, dst, dp, 1);
sp += n;
continue;
default:
return CoderResult.malformedForLength(1);
}
}
return CoderResult.UNDERFLOW;
} finally {
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
} }
return xflow(src, sp, sl, dst, dp, 0);
} }
private CoderResult decodeBufferLoop(ByteBuffer src, private CoderResult decodeBufferLoop(ByteBuffer src,
CharBuffer dst) CharBuffer dst)
{ {
int mark = src.position(); int mark = src.position();
try { int limit = src.limit();
while (src.hasRemaining()) { while (mark < limit) {
int b1 = src.get(); int b1 = src.get();
int b2, b3; if (b1 >= 0) {
switch ((b1 >> 4) & 0x0f) {
case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7:
// 1 byte, 7 bits: 0xxxxxxx // 1 byte, 7 bits: 0xxxxxxx
if (dst.remaining() < 1) if (dst.remaining() < 1)
return CoderResult.OVERFLOW; return xflow(src, mark, 1); //overflow
dst.put((char)b1); dst.put((char)b1);
mark++; mark++;
continue; } else if ((b1 >> 5) == -2) {
case 12: case 13:
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
if (src.remaining() < 1) if (limit - mark < 2|| dst.remaining() < 1)
return CoderResult.UNDERFLOW; return xflow(src, mark, 2);
if (dst.remaining() < 1) int b2 = src.get();
return CoderResult.OVERFLOW; if (isMalformed2(b1, b2))
if (!isContinuation(b2 = src.get())) return malformed(src, mark, 2);
return CoderResult.malformedForLength(1); dst.put((char) (((b1 << 6) ^ b2) ^ 0x0f80));
dst.put((char)(((b1 & 0x1f) << 6) |
((b2 & 0x3f) << 0)));
mark += 2; mark += 2;
continue; } else if ((b1 >> 4) == -2) {
case 14:
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
if (src.remaining() < 2) if (limit - mark < 3 || dst.remaining() < 1)
return CoderResult.UNDERFLOW; return xflow(src, mark, 3);
if (dst.remaining() < 1) int b2 = src.get();
return CoderResult.OVERFLOW; int b3 = src.get();
if (!isContinuation(b2 = src.get())) if (isMalformed3(b1, b2, b3))
return CoderResult.malformedForLength(1); return malformed(src, mark, 3);
if (!isContinuation(b3 = src.get())) dst.put((char) (((b1 << 12) ^ (b2 << 6) ^ b3) ^ 0x1f80));
return CoderResult.malformedForLength(2);
dst.put((char)(((b1 & 0x0f) << 12) |
((b2 & 0x3f) << 06) |
((b3 & 0x3f) << 0)));
mark += 3; mark += 3;
continue; } else if ((b1 >> 3) == -2) {
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
case 15: if (limit - mark < 4 || dst.remaining() < 2)
// 4, 5, or 6 bytes return xflow(src, mark, 4);
int b2 = src.get();
int b4, b5, b6, uc, n; int b3 = src.get();
switch (b1 & 0x0f) { int b4 = src.get();
int uc = ((b1 & 0x07) << 18) |
case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7:
// 4 bytes, 21 bits
if (src.remaining() < 3)
return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = src.get()))
return CoderResult.malformedForLength(1);
if (!isContinuation(b3 = src.get()))
return CoderResult.malformedForLength(2);
if (!isContinuation(b4 = src.get()))
return CoderResult.malformedForLength(3);
uc = (((b1 & 0x07) << 18) |
((b2 & 0x3f) << 12) | ((b2 & 0x3f) << 12) |
((b3 & 0x3f) << 06) | ((b3 & 0x3f) << 06) |
((b4 & 0x3f) << 00)); (b4 & 0x3f);
n = 4; if (isMalformed4(b2, b3, b4) ||
break; !Surrogate.neededFor(uc)) { // shortest form check
return malformed(src, mark, 4);
case 8: case 9: case 10: case 11:
// 5 bytes, 26 bits
if (src.remaining() < 4)
return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = src.get()))
return CoderResult.malformedForLength(1);
if (!isContinuation(b3 = src.get()))
return CoderResult.malformedForLength(2);
if (!isContinuation(b4 = src.get()))
return CoderResult.malformedForLength(3);
if (!isContinuation(b5 = src.get()))
return CoderResult.malformedForLength(4);
uc = (((b1 & 0x03) << 24) |
((b2 & 0x3f) << 18) |
((b3 & 0x3f) << 12) |
((b4 & 0x3f) << 06) |
((b5 & 0x3f) << 00));
n = 5;
break;
case 12: case 13:
// 6 bytes, 31 bits
if (src.remaining() < 5)
return CoderResult.UNDERFLOW;
if (!isContinuation(b2 = src.get()))
return CoderResult.malformedForLength(1);
if (!isContinuation(b3 = src.get()))
return CoderResult.malformedForLength(2);
if (!isContinuation(b4 = src.get()))
return CoderResult.malformedForLength(3);
if (!isContinuation(b5 = src.get()))
return CoderResult.malformedForLength(4);
if (!isContinuation(b6 = src.get()))
return CoderResult.malformedForLength(5);
uc = (((b1 & 0x01) << 30) |
((b2 & 0x3f) << 24) |
((b3 & 0x3f) << 18) |
((b4 & 0x3f) << 12) |
((b5 & 0x3f) << 06) |
((b6 & 0x3f)));
n = 6;
break;
default:
return CoderResult.malformedForLength(1);
} }
dst.put(Surrogate.high(uc));
if (sgg.generate(uc, n, dst) < 0) dst.put(Surrogate.low(uc));
return sgg.error(); mark += 4;
mark += n; } else {
continue; return malformed(src, mark, 1);
default:
return CoderResult.malformedForLength(1);
} }
}
return CoderResult.UNDERFLOW;
} finally {
src.position(mark);
} }
return xflow(src, mark, 0);
} }
protected CoderResult decodeLoop(ByteBuffer src, protected CoderResult decodeLoop(ByteBuffer src,
@ -377,10 +325,8 @@ class UTF_8 extends Unicode
else else
return decodeBufferLoop(src, dst); return decodeBufferLoop(src, dst);
} }
} }
private static class Encoder extends CharsetEncoder { private static class Encoder extends CharsetEncoder {
private Encoder(Charset cs) { private Encoder(Charset cs) {
@ -391,141 +337,126 @@ class UTF_8 extends Unicode
return !Surrogate.is(c); return !Surrogate.is(c);
} }
private final Surrogate.Parser sgp = new Surrogate.Parser(); public boolean isLegalReplacement(byte[] repl) {
return ((repl.length == 1 && repl[0] >= 0) ||
super.isLegalReplacement(repl));
}
private static CoderResult overflow(CharBuffer src, int sp,
ByteBuffer dst, int dp) {
updatePositions(src, sp, dst, dp);
return CoderResult.OVERFLOW;
}
private static CoderResult overflow(CharBuffer src, int mark) {
src.position(mark);
return CoderResult.OVERFLOW;
}
private Surrogate.Parser sgp;
private CoderResult encodeArrayLoop(CharBuffer src, private CoderResult encodeArrayLoop(CharBuffer src,
ByteBuffer dst) ByteBuffer dst)
{ {
char[] sa = src.array(); char[] sa = src.array();
int sp = src.arrayOffset() + src.position(); int sp = src.arrayOffset() + src.position();
int sl = src.arrayOffset() + src.limit(); int sl = src.arrayOffset() + src.limit();
assert (sp <= sl);
sp = (sp <= sl ? sp : sl);
byte[] da = dst.array(); byte[] da = dst.array();
int dp = dst.arrayOffset() + dst.position(); int dp = dst.arrayOffset() + dst.position();
int dl = dst.arrayOffset() + dst.limit(); int dl = dst.arrayOffset() + dst.limit();
assert (dp <= dl); int dlASCII = dp + Math.min(sl - sp, dl - dp);
dp = (dp <= dl ? dp : dl);
try { //ASCII only loop
while (dp < dlASCII && sa[sp] < '\u0080')
da[dp++] = (byte) sa[sp++];
while (sp < sl) { while (sp < sl) {
char c = sa[sp]; int c = sa[sp];
if (c < 0x80) { if (c < 0x80) {
// Have at most seven bits // Have at most seven bits
if (dp >= dl) if (dp >= dl)
return CoderResult.OVERFLOW; return overflow(src, sp, dst, dp);
da[dp++] = (byte)c; da[dp++] = (byte)c;
sp++; } else if (c < 0x800) {
continue;
}
if (!Surrogate.is(c)) {
// 2 bytes, 11 bits // 2 bytes, 11 bits
if (c < 0x800) {
if (dl - dp < 2) if (dl - dp < 2)
return CoderResult.OVERFLOW; return overflow(src, sp, dst, dp);
da[dp++] = (byte)(0xc0 | ((c >> 06))); da[dp++] = (byte)(0xc0 | ((c >> 06)));
da[dp++] = (byte)(0x80 | ((c >> 00) & 0x3f)); da[dp++] = (byte)(0x80 | (c & 0x3f));
sp++; } else if (Surrogate.is(c)) {
continue;
}
if (c <= '\uFFFF') {
// 3 bytes, 16 bits
if (dl - dp < 3)
return CoderResult.OVERFLOW;
da[dp++] = (byte)(0xe0 | ((c >> 12)));
da[dp++] = (byte)(0x80 | ((c >> 06) & 0x3f));
da[dp++] = (byte)(0x80 | ((c >> 00) & 0x3f));
sp++;
continue;
}
}
// Have a surrogate pair // Have a surrogate pair
int uc = sgp.parse(c, sa, sp, sl); if (sgp == null)
if (uc < 0) sgp = new Surrogate.Parser();
int uc = sgp.parse((char)c, sa, sp, sl);
if (uc < 0) {
updatePositions(src, sp, dst, dp);
return sgp.error(); return sgp.error();
if (uc < 0x200000) { }
if (dl - dp < 4) if (dl - dp < 4)
return CoderResult.OVERFLOW; return overflow(src, sp, dst, dp);
da[dp++] = (byte)(0xf0 | ((uc >> 18))); da[dp++] = (byte)(0xf0 | ((uc >> 18)));
da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f));
da[dp++] = (byte)(0x80 | ((uc >> 06) & 0x3f)); da[dp++] = (byte)(0x80 | ((uc >> 06) & 0x3f));
da[dp++] = (byte)(0x80 | ((uc >> 00) & 0x3f)); da[dp++] = (byte)(0x80 | (uc & 0x3f));
sp += sgp.increment(); sp++; // 2 chars
continue; } else {
// 3 bytes, 16 bits
if (dl - dp < 3)
return overflow(src, sp, dst, dp);
da[dp++] = (byte)(0xe0 | ((c >> 12)));
da[dp++] = (byte)(0x80 | ((c >> 06) & 0x3f));
da[dp++] = (byte)(0x80 | (c & 0x3f));
} }
assert false; sp++;
} }
updatePositions(src, sp, dst, dp);
return CoderResult.UNDERFLOW; return CoderResult.UNDERFLOW;
} finally {
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
}
} }
private CoderResult encodeBufferLoop(CharBuffer src, private CoderResult encodeBufferLoop(CharBuffer src,
ByteBuffer dst) ByteBuffer dst)
{ {
int mark = src.position(); int mark = src.position();
try {
while (src.hasRemaining()) { while (src.hasRemaining()) {
char c = src.get(); int c = src.get();
if (c < 0x80) { if (c < 0x80) {
// Have at most seven bits // Have at most seven bits
if (!dst.hasRemaining()) if (!dst.hasRemaining())
return CoderResult.OVERFLOW; return overflow(src, mark);
dst.put((byte)c); dst.put((byte)c);
mark++; } else if (c < 0x800) {
continue;
}
if (!Surrogate.is(c)) {
if (c < 0x800) {
// 2 bytes, 11 bits // 2 bytes, 11 bits
if (dst.remaining() < 2) if (dst.remaining() < 2)
return CoderResult.OVERFLOW; return overflow(src, mark);
dst.put((byte)(0xc0 | ((c >> 06)))); dst.put((byte)(0xc0 | ((c >> 06))));
dst.put((byte)(0x80 | ((c >> 00) & 0x3f))); dst.put((byte)(0x80 | (c & 0x3f)));
mark++; } else if (Surrogate.is(c)) {
continue;
}
if (c <= '\uFFFF') {
// 3 bytes, 16 bits
if (dst.remaining() < 3)
return CoderResult.OVERFLOW;
dst.put((byte)(0xe0 | ((c >> 12))));
dst.put((byte)(0x80 | ((c >> 06) & 0x3f)));
dst.put((byte)(0x80 | ((c >> 00) & 0x3f)));
mark++;
continue;
}
}
// Have a surrogate pair // Have a surrogate pair
int uc = sgp.parse(c, src); if (sgp == null)
if (uc < 0) sgp = new Surrogate.Parser();
int uc = sgp.parse((char)c, src);
if (uc < 0) {
src.position(mark);
return sgp.error(); return sgp.error();
if (uc < 0x200000) { }
if (dst.remaining() < 4) if (dst.remaining() < 4)
return CoderResult.OVERFLOW; return overflow(src, mark);
dst.put((byte)(0xf0 | ((uc >> 18)))); dst.put((byte)(0xf0 | ((uc >> 18))));
dst.put((byte)(0x80 | ((uc >> 12) & 0x3f))); dst.put((byte)(0x80 | ((uc >> 12) & 0x3f)));
dst.put((byte)(0x80 | ((uc >> 06) & 0x3f))); dst.put((byte)(0x80 | ((uc >> 06) & 0x3f)));
dst.put((byte)(0x80 | ((uc >> 00) & 0x3f))); dst.put((byte)(0x80 | (uc & 0x3f)));
mark += sgp.increment(); mark++; //2 chars
continue; } else {
// 3 bytes, 16 bits
if (dst.remaining() < 3)
return overflow(src, mark);
dst.put((byte)(0xe0 | ((c >> 12))));
dst.put((byte)(0x80 | ((c >> 06) & 0x3f)));
dst.put((byte)(0x80 | (c & 0x3f)));
} }
assert false; mark++;
} }
return CoderResult.UNDERFLOW;
} finally {
src.position(mark); src.position(mark);
} return CoderResult.UNDERFLOW;
} }
protected final CoderResult encodeLoop(CharBuffer src, protected final CoderResult encodeLoop(CharBuffer src,
@ -536,7 +467,5 @@ class UTF_8 extends Unicode
else else
return encodeBufferLoop(src, dst); return encodeBufferLoop(src, dst);
} }
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,6 +50,7 @@ class DerIndefLenConverter {
private byte[] data, newData; private byte[] data, newData;
private int newDataPos, dataPos, dataSize, index; private int newDataPos, dataPos, dataSize, index;
private int unresolved = 0;
private ArrayList<Object> ndefsList = new ArrayList<Object>(); private ArrayList<Object> ndefsList = new ArrayList<Object>();
@ -113,6 +114,7 @@ class DerIndefLenConverter {
numOfEncapsulatedLenBytes; numOfEncapsulatedLenBytes;
byte[] sectionLenBytes = getLengthBytes(sectionLen); byte[] sectionLenBytes = getLengthBytes(sectionLen);
ndefsList.set(index, sectionLenBytes); ndefsList.set(index, sectionLenBytes);
unresolved--;
// Add the number of bytes required to represent this section // Add the number of bytes required to represent this section
// to the total number of length bytes, // to the total number of length bytes,
@ -149,6 +151,7 @@ class DerIndefLenConverter {
int lenByte = data[dataPos++] & 0xff; int lenByte = data[dataPos++] & 0xff;
if (isIndefinite(lenByte)) { if (isIndefinite(lenByte)) {
ndefsList.add(new Integer(dataPos)); ndefsList.add(new Integer(dataPos));
unresolved++;
return curLen; return curLen;
} }
if (isLongForm(lenByte)) { if (isLongForm(lenByte)) {
@ -308,15 +311,21 @@ class DerIndefLenConverter {
dataPos=0; index=0; dataPos=0; index=0;
dataSize = data.length; dataSize = data.length;
int len=0; int len=0;
int unused = 0;
// parse and set up the vectors of all the indefinite-lengths // parse and set up the vectors of all the indefinite-lengths
while (dataPos < dataSize) { while (dataPos < dataSize) {
parseTag(); parseTag();
len = parseLength(); len = parseLength();
parseValue(len); parseValue(len);
if (unresolved == 0) {
unused = dataSize - dataPos;
dataSize = dataPos;
break;
}
} }
newData = new byte[dataSize + numOfTotalLenBytes]; newData = new byte[dataSize + numOfTotalLenBytes + unused];
dataPos=0; newDataPos=0; index=0; dataPos=0; newDataPos=0; index=0;
// write out the new byte array replacing all the indefinite-lengths // write out the new byte array replacing all the indefinite-lengths
@ -325,6 +334,8 @@ class DerIndefLenConverter {
writeTag(); writeTag();
writeLengthAndValue(); writeLengthAndValue();
} }
System.arraycopy(indefData, dataSize,
newData, dataSize + numOfTotalLenBytes, unused);
return newData; return newData;
} }

View file

@ -56,7 +56,7 @@ public class JMap {
private static String FORCE_SA_OPTION = "-F"; private static String FORCE_SA_OPTION = "-F";
// Default option (if nothing provided) // Default option (if nothing provided)
private static String DEFAULT_OPTION = "-heap"; private static String DEFAULT_OPTION = "-pmap";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (args.length == 0) { if (args.length == 0) {
@ -147,6 +147,7 @@ public class JMap {
// Invoke SA tool with the given arguments // Invoke SA tool with the given arguments
private static void runTool(String option, String args[]) throws Exception { private static void runTool(String option, String args[]) throws Exception {
String[][] tools = { String[][] tools = {
{ "-pmap", "sun.jvm.hotspot.tools.PMap" },
{ "-heap", "sun.jvm.hotspot.tools.HeapSummary" }, { "-heap", "sun.jvm.hotspot.tools.HeapSummary" },
{ "-heap:format=b", "sun.jvm.hotspot.tools.HeapDumper" }, { "-heap:format=b", "sun.jvm.hotspot.tools.HeapDumper" },
{ "-histo", "sun.jvm.hotspot.tools.ObjectHistogram" }, { "-histo", "sun.jvm.hotspot.tools.ObjectHistogram" },

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,15 +23,14 @@
* have any questions. * have any questions.
*/ */
#include <jni.h> #include <jni.h>
#include "JPLISAgent.h" #include "JPLISAgent.h"
#include "JPLISAssert.h" #include "JPLISAssert.h"
#include "Utilities.h" #include "Utilities.h"
#include "JavaExceptions.h" #include "JavaExceptions.h"
#include "FileSystemSupport.h" /* For uintptr_t */
#include "sun_instrument_InstrumentationImpl.h" #include "sun_instrument_InstrumentationImpl.h"
#include "typedefs.h"
/* /*
* Copyright 2003 Wily Technology, Inc. * Copyright 2003 Wily Technology, Inc.

View file

@ -38,10 +38,9 @@
#include "JavaExceptions.h" #include "JavaExceptions.h"
#include "EncodingSupport.h" #include "EncodingSupport.h"
#include "FileSystemSupport.h" /* MAXPATHLEN */ #include "FileSystemSupport.h" /* For MAXPATHLEN & uintptr_t */
#include "sun_instrument_InstrumentationImpl.h" #include "sun_instrument_InstrumentationImpl.h"
#include "typedefs.h"
/* /*
* The JPLISAgent manages the initialization all of the Java programming language Agents. * The JPLISAgent manages the initialization all of the Java programming language Agents.

View file

@ -948,90 +948,8 @@ JVM_ReleaseUTF(const char *utf);
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2); JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);
/* Constants in class files */ /* Get classfile constants */
#include "classfile_constants.h"
#define JVM_ACC_PUBLIC 0x0001 /* visible to everyone */
#define JVM_ACC_PRIVATE 0x0002 /* visible only to the defining class */
#define JVM_ACC_PROTECTED 0x0004 /* visible to subclasses */
#define JVM_ACC_STATIC 0x0008 /* instance variable is static */
#define JVM_ACC_FINAL 0x0010 /* no further subclassing, overriding */
#define JVM_ACC_SYNCHRONIZED 0x0020 /* wrap method call in monitor lock */
#define JVM_ACC_SUPER 0x0020 /* funky handling of invokespecial */
#define JVM_ACC_VOLATILE 0x0040 /* can not cache in registers */
#define JVM_ACC_BRIDGE 0x0040 /* bridge method generated by compiler */
#define JVM_ACC_TRANSIENT 0x0080 /* not persistant */
#define JVM_ACC_VARARGS 0x0080 /* method declared with variable number of args */
#define JVM_ACC_NATIVE 0x0100 /* implemented in C */
#define JVM_ACC_INTERFACE 0x0200 /* class is an interface */
#define JVM_ACC_ABSTRACT 0x0400 /* no definition provided */
#define JVM_ACC_STRICT 0x0800 /* strict floating point */
#define JVM_ACC_SYNTHETIC 0x1000 /* compiler-generated class, method or field */
#define JVM_ACC_ANNOTATION 0x2000 /* annotation type */
#define JVM_ACC_ENUM 0x4000 /* field is declared as element of enum */
#define JVM_ACC_PUBLIC_BIT 0
#define JVM_ACC_PRIVATE_BIT 1
#define JVM_ACC_PROTECTED_BIT 2
#define JVM_ACC_STATIC_BIT 3
#define JVM_ACC_FINAL_BIT 4
#define JVM_ACC_SYNCHRONIZED_BIT 5
#define JVM_ACC_SUPER_BIT 5
#define JVM_ACC_VOLATILE_BIT 6
#define JVM_ACC_BRIDGE_BIT 6
#define JVM_ACC_TRANSIENT_BIT 7
#define JVM_ACC_VARARGS_BIT 7
#define JVM_ACC_NATIVE_BIT 8
#define JVM_ACC_INTERFACE_BIT 9
#define JVM_ACC_ABSTRACT_BIT 10
#define JVM_ACC_STRICT_BIT 11
#define JVM_ACC_SYNTHETIC_BIT 12
#define JVM_ACC_ANNOTATION_BIT 13
#define JVM_ACC_ENUM_BIT 14
enum {
JVM_CONSTANT_Utf8 = 1,
JVM_CONSTANT_Unicode, /* unused */
JVM_CONSTANT_Integer,
JVM_CONSTANT_Float,
JVM_CONSTANT_Long,
JVM_CONSTANT_Double,
JVM_CONSTANT_Class,
JVM_CONSTANT_String,
JVM_CONSTANT_Fieldref,
JVM_CONSTANT_Methodref,
JVM_CONSTANT_InterfaceMethodref,
JVM_CONSTANT_NameAndType
};
/* Used in the newarray instruction. */
#define JVM_T_BOOLEAN 4
#define JVM_T_CHAR 5
#define JVM_T_FLOAT 6
#define JVM_T_DOUBLE 7
#define JVM_T_BYTE 8
#define JVM_T_SHORT 9
#define JVM_T_INT 10
#define JVM_T_LONG 11
/* JVM method signatures */
#define JVM_SIGNATURE_ARRAY '['
#define JVM_SIGNATURE_BYTE 'B'
#define JVM_SIGNATURE_CHAR 'C'
#define JVM_SIGNATURE_CLASS 'L'
#define JVM_SIGNATURE_ENDCLASS ';'
#define JVM_SIGNATURE_ENUM 'E'
#define JVM_SIGNATURE_FLOAT 'F'
#define JVM_SIGNATURE_DOUBLE 'D'
#define JVM_SIGNATURE_FUNC '('
#define JVM_SIGNATURE_ENDFUNC ')'
#define JVM_SIGNATURE_INT 'I'
#define JVM_SIGNATURE_LONG 'J'
#define JVM_SIGNATURE_SHORT 'S'
#define JVM_SIGNATURE_VOID 'V'
#define JVM_SIGNATURE_BOOLEAN 'Z'
/* /*
* A function defined by the byte-code verifier and called by the VM. * A function defined by the byte-code verifier and called by the VM.
@ -1329,23 +1247,6 @@ JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen);
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen); JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen);
/*
* These routines are only reentrant on Windows
*/
#ifdef WIN32
JNIEXPORT struct protoent * JNICALL
JVM_GetProtoByName(char* name);
JNIEXPORT struct hostent* JNICALL
JVM_GetHostByAddr(const char* name, int len, int type);
JNIEXPORT struct hostent* JNICALL
JVM_GetHostByName(char* name);
#endif /* _WINDOWS */
JNIEXPORT int JNICALL JNIEXPORT int JNICALL
JVM_GetHostName(char* name, int namelen); JVM_GetHostName(char* name, int namelen);

View file

@ -1,268 +0,0 @@
/*
* Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _JAVASOFT_OPCODES_H_
#define _JAVASOFT_OPCODES_H_
typedef enum {
opc_nop = 0,
opc_aconst_null = 1,
opc_iconst_m1 = 2,
opc_iconst_0 = 3,
opc_iconst_1 = 4,
opc_iconst_2 = 5,
opc_iconst_3 = 6,
opc_iconst_4 = 7,
opc_iconst_5 = 8,
opc_lconst_0 = 9,
opc_lconst_1 = 10,
opc_fconst_0 = 11,
opc_fconst_1 = 12,
opc_fconst_2 = 13,
opc_dconst_0 = 14,
opc_dconst_1 = 15,
opc_bipush = 16,
opc_sipush = 17,
opc_ldc = 18,
opc_ldc_w = 19,
opc_ldc2_w = 20,
opc_iload = 21,
opc_lload = 22,
opc_fload = 23,
opc_dload = 24,
opc_aload = 25,
opc_iload_0 = 26,
opc_iload_1 = 27,
opc_iload_2 = 28,
opc_iload_3 = 29,
opc_lload_0 = 30,
opc_lload_1 = 31,
opc_lload_2 = 32,
opc_lload_3 = 33,
opc_fload_0 = 34,
opc_fload_1 = 35,
opc_fload_2 = 36,
opc_fload_3 = 37,
opc_dload_0 = 38,
opc_dload_1 = 39,
opc_dload_2 = 40,
opc_dload_3 = 41,
opc_aload_0 = 42,
opc_aload_1 = 43,
opc_aload_2 = 44,
opc_aload_3 = 45,
opc_iaload = 46,
opc_laload = 47,
opc_faload = 48,
opc_daload = 49,
opc_aaload = 50,
opc_baload = 51,
opc_caload = 52,
opc_saload = 53,
opc_istore = 54,
opc_lstore = 55,
opc_fstore = 56,
opc_dstore = 57,
opc_astore = 58,
opc_istore_0 = 59,
opc_istore_1 = 60,
opc_istore_2 = 61,
opc_istore_3 = 62,
opc_lstore_0 = 63,
opc_lstore_1 = 64,
opc_lstore_2 = 65,
opc_lstore_3 = 66,
opc_fstore_0 = 67,
opc_fstore_1 = 68,
opc_fstore_2 = 69,
opc_fstore_3 = 70,
opc_dstore_0 = 71,
opc_dstore_1 = 72,
opc_dstore_2 = 73,
opc_dstore_3 = 74,
opc_astore_0 = 75,
opc_astore_1 = 76,
opc_astore_2 = 77,
opc_astore_3 = 78,
opc_iastore = 79,
opc_lastore = 80,
opc_fastore = 81,
opc_dastore = 82,
opc_aastore = 83,
opc_bastore = 84,
opc_castore = 85,
opc_sastore = 86,
opc_pop = 87,
opc_pop2 = 88,
opc_dup = 89,
opc_dup_x1 = 90,
opc_dup_x2 = 91,
opc_dup2 = 92,
opc_dup2_x1 = 93,
opc_dup2_x2 = 94,
opc_swap = 95,
opc_iadd = 96,
opc_ladd = 97,
opc_fadd = 98,
opc_dadd = 99,
opc_isub = 100,
opc_lsub = 101,
opc_fsub = 102,
opc_dsub = 103,
opc_imul = 104,
opc_lmul = 105,
opc_fmul = 106,
opc_dmul = 107,
opc_idiv = 108,
opc_ldiv = 109,
opc_fdiv = 110,
opc_ddiv = 111,
opc_irem = 112,
opc_lrem = 113,
opc_frem = 114,
opc_drem = 115,
opc_ineg = 116,
opc_lneg = 117,
opc_fneg = 118,
opc_dneg = 119,
opc_ishl = 120,
opc_lshl = 121,
opc_ishr = 122,
opc_lshr = 123,
opc_iushr = 124,
opc_lushr = 125,
opc_iand = 126,
opc_land = 127,
opc_ior = 128,
opc_lor = 129,
opc_ixor = 130,
opc_lxor = 131,
opc_iinc = 132,
opc_i2l = 133,
opc_i2f = 134,
opc_i2d = 135,
opc_l2i = 136,
opc_l2f = 137,
opc_l2d = 138,
opc_f2i = 139,
opc_f2l = 140,
opc_f2d = 141,
opc_d2i = 142,
opc_d2l = 143,
opc_d2f = 144,
opc_i2b = 145,
opc_i2c = 146,
opc_i2s = 147,
opc_lcmp = 148,
opc_fcmpl = 149,
opc_fcmpg = 150,
opc_dcmpl = 151,
opc_dcmpg = 152,
opc_ifeq = 153,
opc_ifne = 154,
opc_iflt = 155,
opc_ifge = 156,
opc_ifgt = 157,
opc_ifle = 158,
opc_if_icmpeq = 159,
opc_if_icmpne = 160,
opc_if_icmplt = 161,
opc_if_icmpge = 162,
opc_if_icmpgt = 163,
opc_if_icmple = 164,
opc_if_acmpeq = 165,
opc_if_acmpne = 166,
opc_goto = 167,
opc_jsr = 168,
opc_ret = 169,
opc_tableswitch = 170,
opc_lookupswitch = 171,
opc_ireturn = 172,
opc_lreturn = 173,
opc_freturn = 174,
opc_dreturn = 175,
opc_areturn = 176,
opc_return = 177,
opc_getstatic = 178,
opc_putstatic = 179,
opc_getfield = 180,
opc_putfield = 181,
opc_invokevirtual = 182,
opc_invokespecial = 183,
opc_invokestatic = 184,
opc_invokeinterface = 185,
opc_xxxunusedxxx = 186,
opc_new = 187,
opc_newarray = 188,
opc_anewarray = 189,
opc_arraylength = 190,
opc_athrow = 191,
opc_checkcast = 192,
opc_instanceof = 193,
opc_monitorenter = 194,
opc_monitorexit = 195,
opc_wide = 196,
opc_multianewarray = 197,
opc_ifnull = 198,
opc_ifnonnull = 199,
opc_goto_w = 200,
opc_jsr_w = 201,
opc_breakpoint = 202,
opc_ldc_quick = 203,
opc_ldc_w_quick = 204,
opc_ldc2_w_quick = 205,
opc_getfield_quick = 206,
opc_putfield_quick = 207,
opc_getfield2_quick = 208,
opc_putfield2_quick = 209,
opc_getstatic_quick = 210,
opc_putstatic_quick = 211,
opc_getstatic2_quick = 212,
opc_putstatic2_quick = 213,
opc_invokevirtual_quick = 214,
opc_invokenonvirtual_quick = 215,
opc_invokesuper_quick = 216,
opc_invokestatic_quick = 217,
opc_invokeinterface_quick = 218,
opc_invokevirtualobject_quick = 219,
opc_invokeignored_quick = 220,
opc_new_quick = 221,
opc_anewarray_quick = 222,
opc_multianewarray_quick = 223,
opc_checkcast_quick = 224,
opc_instanceof_quick = 225,
opc_invokevirtual_quick_w = 226,
opc_getfield_quick_w = 227,
opc_putfield_quick_w = 228,
opc_nonnull_quick = 229,
opc_first_unused_index = 230,
opc_software = 254,
opc_hardware = 255,
opc_dummy = (int)0xF0000000U /* portability change, opc_invokeinit in the
* verifier requires more than 8 bits.
*/
} opcode_type;
#endif /* !_JAVASOFT_OPCODES_H_ */

View file

@ -1,283 +0,0 @@
/*
* Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
const short opcode_length[256] = {
1, /* nop */
1, /* aconst_null */
1, /* iconst_m1 */
1, /* iconst_0 */
1, /* iconst_1 */
1, /* iconst_2 */
1, /* iconst_3 */
1, /* iconst_4 */
1, /* iconst_5 */
1, /* lconst_0 */
1, /* lconst_1 */
1, /* fconst_0 */
1, /* fconst_1 */
1, /* fconst_2 */
1, /* dconst_0 */
1, /* dconst_1 */
2, /* bipush */
3, /* sipush */
2, /* ldc */
3, /* ldc_w */
3, /* ldc2_w */
2, /* iload */
2, /* lload */
2, /* fload */
2, /* dload */
2, /* aload */
1, /* iload_0 */
1, /* iload_1 */
1, /* iload_2 */
1, /* iload_3 */
1, /* lload_0 */
1, /* lload_1 */
1, /* lload_2 */
1, /* lload_3 */
1, /* fload_0 */
1, /* fload_1 */
1, /* fload_2 */
1, /* fload_3 */
1, /* dload_0 */
1, /* dload_1 */
1, /* dload_2 */
1, /* dload_3 */
1, /* aload_0 */
1, /* aload_1 */
1, /* aload_2 */
1, /* aload_3 */
1, /* iaload */
1, /* laload */
1, /* faload */
1, /* daload */
1, /* aaload */
1, /* baload */
1, /* caload */
1, /* saload */
2, /* istore */
2, /* lstore */
2, /* fstore */
2, /* dstore */
2, /* astore */
1, /* istore_0 */
1, /* istore_1 */
1, /* istore_2 */
1, /* istore_3 */
1, /* lstore_0 */
1, /* lstore_1 */
1, /* lstore_2 */
1, /* lstore_3 */
1, /* fstore_0 */
1, /* fstore_1 */
1, /* fstore_2 */
1, /* fstore_3 */
1, /* dstore_0 */
1, /* dstore_1 */
1, /* dstore_2 */
1, /* dstore_3 */
1, /* astore_0 */
1, /* astore_1 */
1, /* astore_2 */
1, /* astore_3 */
1, /* iastore */
1, /* lastore */
1, /* fastore */
1, /* dastore */
1, /* aastore */
1, /* bastore */
1, /* castore */
1, /* sastore */
1, /* pop */
1, /* pop2 */
1, /* dup */
1, /* dup_x1 */
1, /* dup_x2 */
1, /* dup2 */
1, /* dup2_x1 */
1, /* dup2_x2 */
1, /* swap */
1, /* iadd */
1, /* ladd */
1, /* fadd */
1, /* dadd */
1, /* isub */
1, /* lsub */
1, /* fsub */
1, /* dsub */
1, /* imul */
1, /* lmul */
1, /* fmul */
1, /* dmul */
1, /* idiv */
1, /* ldiv */
1, /* fdiv */
1, /* ddiv */
1, /* irem */
1, /* lrem */
1, /* frem */
1, /* drem */
1, /* ineg */
1, /* lneg */
1, /* fneg */
1, /* dneg */
1, /* ishl */
1, /* lshl */
1, /* ishr */
1, /* lshr */
1, /* iushr */
1, /* lushr */
1, /* iand */
1, /* land */
1, /* ior */
1, /* lor */
1, /* ixor */
1, /* lxor */
3, /* iinc */
1, /* i2l */
1, /* i2f */
1, /* i2d */
1, /* l2i */
1, /* l2f */
1, /* l2d */
1, /* f2i */
1, /* f2l */
1, /* f2d */
1, /* d2i */
1, /* d2l */
1, /* d2f */
1, /* i2b */
1, /* i2c */
1, /* i2s */
1, /* lcmp */
1, /* fcmpl */
1, /* fcmpg */
1, /* dcmpl */
1, /* dcmpg */
3, /* ifeq */
3, /* ifne */
3, /* iflt */
3, /* ifge */
3, /* ifgt */
3, /* ifle */
3, /* if_icmpeq */
3, /* if_icmpne */
3, /* if_icmplt */
3, /* if_icmpge */
3, /* if_icmpgt */
3, /* if_icmple */
3, /* if_acmpeq */
3, /* if_acmpne */
3, /* goto */
3, /* jsr */
2, /* ret */
99, /* tableswitch */
99, /* lookupswitch */
1, /* ireturn */
1, /* lreturn */
1, /* freturn */
1, /* dreturn */
1, /* areturn */
1, /* return */
3, /* getstatic */
3, /* putstatic */
3, /* getfield */
3, /* putfield */
3, /* invokevirtual */
3, /* invokespecial */
3, /* invokestatic */
5, /* invokeinterface */
0, /* xxxunusedxxx */
3, /* new */
2, /* newarray */
3, /* anewarray */
1, /* arraylength */
1, /* athrow */
3, /* checkcast */
3, /* instanceof */
1, /* monitorenter */
1, /* monitorexit */
0, /* wide */
4, /* multianewarray */
3, /* ifnull */
3, /* ifnonnull */
5, /* goto_w */
5, /* jsr_w */
1, /* breakpoint */
2, /* ldc_quick */
3, /* ldc_w_quick */
3, /* ldc2_w_quick */
3, /* getfield_quick */
3, /* putfield_quick */
3, /* getfield2_quick */
3, /* putfield2_quick */
3, /* getstatic_quick */
3, /* putstatic_quick */
3, /* getstatic2_quick */
3, /* putstatic2_quick */
3, /* invokevirtual_quick */
3, /* invokenonvirtual_quick */
3, /* invokesuper_quick */
3, /* invokestatic_quick */
5, /* invokeinterface_quick */
3, /* invokevirtualobject_quick */
3, /* invokeignored_quick */
3, /* new_quick */
3, /* anewarray_quick */
4, /* multianewarray_quick */
3, /* checkcast_quick */
3, /* instanceof_quick */
3, /* invokevirtual_quick_w */
3, /* getfield_quick_w */
3, /* putfield_quick_w */
1, /* nonnull_quick */
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
-1,
};

View file

@ -1,301 +0,0 @@
# Copyright 1994-2007 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# Any line that doesn't have a-z in the 1st column is a comment.
#
# The first column is the name of the opcodes. The second column is the
# total length of the instruction. We use 99 for tableswitch and
# tablelookup, which must always be treated as special cases.
#
# The third and fourth colum give what the opcode pops off the stack, and
# what it then pushes back onto the stack
# - <no effect on stack>
# I integer
# L long integer
# F float
# D double float
# A address [array or object]
# O object only
# R return address (for jsr)
# a integer, array, or object
# ? unknown
# [I], [L], [F], [D], [A], [B], [C], [?]
# array of integer, long, float, double, address, bytes,
# chars, or anything
# 1,2,3,4,+ used by stack duplicating/popping routines.
#
# 1,2,3,4 represent >>any<< stack type except long or double. Two numbers
# separated by a + (in the third column) indicate that the two, together, can
# be used for a double or long. (Or they can represent two non-long items).
#
# The fifth column provides an *approximate* relative cost of executing the
# opcode. It is used by the instruction profiler. See profiler.h for
# blurb.
nop 1 - - 1 /* nop */
aconst_null 1 - A 1 /* push null object */
iconst_m1 1 - I 1 /* push integer constant -1 */
iconst_0 1 - I 1 /* push integer constant 0 */
iconst_1 1 - I 1 /* push integer constant 1 */
iconst_2 1 - I 1 /* push integer constant 2 */
iconst_3 1 - I 1 /* push integer constant 3 */
iconst_4 1 - I 1 /* push integer constant 4 */
iconst_5 1 - I 1 /* push integer constant 5 */
lconst_0 1 - L 1 /* push long 0L */
lconst_1 1 - L 1 /* push long 1L */
fconst_0 1 - F 1 /* push float constant 0.0 */
fconst_1 1 - F 1 /* push float constant 1.0 */
fconst_2 1 - F 1 /* push float constant 2.0 */
dconst_0 1 - D 1 /* push double float constant 0.0d */
dconst_1 1 - D 1 /* push double float constant 1.0d */
bipush 2 - I 1 /* push byte-sized value */
sipush 3 - I 1 /* push two-byte value */
ldc 2 - ? 1 /* load a const from constant table */
ldc_w 3 - ? 1
ldc2_w 3 - ? 1 /* load a 2-word constant . . . */
iload 2 - I 1 /* load local integer variable */
lload 2 - L 1 /* load local long variable */
fload 2 - F 1 /* load local floating variable */
dload 2 - D 1 /* load local double variable */
aload 2 - A 1 /* load local object variable */
iload_0 1 - I 1 /* load local integer variable #0 */
iload_1 1 - I 1 /* load local integer variable #1 */
iload_2 1 - I 1 /* load local integer variable #2 */
iload_3 1 - I 1 /* load local integer variable #3 */
lload_0 1 - L 1 /* load local long variable #0 */
lload_1 1 - L 1 /* load local long variable #1 */
lload_2 1 - L 1 /* load local long variable #2 */
lload_3 1 - L 1 /* load local long variable #3 */
fload_0 1 - F 1 /* load local float variable #0 */
fload_1 1 - F 1 /* load local float variable #1 */
fload_2 1 - F 1 /* load local float variable #2 */
fload_3 1 - F 1 /* load local float variable #3 */
dload_0 1 - D 1 /* load lcl double float variable #0 */
dload_1 1 - D 1 /* load lcl double float variable #1 */
dload_2 1 - D 1 /* load lcl double float variable #2 */
dload_3 1 - D 1 /* load lcl double float variable #3 */
aload_0 1 - A 1 /* load local object variable #0 */
aload_1 1 - A 1 /* load local object variable #1 */
aload_2 1 - A 1 /* load local object variable #2 */
aload_3 1 - A 1 /* load local object variable #3 */
iaload 1 [I]I I 1 /* load from array of integer */
laload 1 [L]I L 1 /* load from array of long */
faload 1 [F]I F 1 /* load from array of float */
daload 1 [D]I D 1 /* load from array of double */
aaload 1 [A]I A 1 /* load from array of object */
baload 1 [B]I I 1 /* load from array of (signed) bytes */
caload 1 [C]I I 1 /* load from array of chars */
saload 1 [S]I I 1 /* load from array of (signed) shorts */
istore 2 I - 1 /* store local integer variable */
lstore 2 L - 1 /* store local long variable */
fstore 2 F - 1 /* store local float variable */
dstore 2 D - 1 /* store local double variable */
astore 2 A - 1 /* store local object variable */
istore_0 1 I - 1 /* store local integer variable #0 */
istore_1 1 I - 1 /* store local integer variable #1 */
istore_2 1 I - 1 /* store local integer variable #2 */
istore_3 1 I - 1 /* store local integer variable #3 */
lstore_0 1 L - 1 /* store local long variable #0 */
lstore_1 1 L - 1 /* store local long variable #1 */
lstore_2 1 L - 1 /* store local long variable #2 */
lstore_3 1 L - 1 /* store local long variable #3 */
fstore_0 1 F - 1 /* store local float variable #0 */
fstore_1 1 F - 1 /* store local float variable #1 */
fstore_2 1 F - 1 /* store local float variable #2 */
fstore_3 1 F - 1 /* store local float variable #3 */
dstore_0 1 D - 1 /* store lcl double float variable #0 */
dstore_1 1 D - 1 /* store lcl double float variable #1 */
dstore_2 1 D - 1 /* store lcl double float variable #2 */
dstore_3 1 D - 1 /* store lcl double float variable #3 */
astore_0 1 A - 1 /* store local object variable #0 */
astore_1 1 A - 1 /* store local object variable #1 */
astore_2 1 A - 1 /* store local object variable #2 */
astore_3 1 A - 1 /* store local object variable #3 */
iastore 1 [I]II - 1 /* store into array of int */
lastore 1 [L]IL - 1 /* store into array of long */
fastore 1 [F]IF - 1 /* store into array of float */
dastore 1 [D]ID - 1 /* store into array of double float */
aastore 1 [A]IA - 1 /* store into array of object */
bastore 1 [B]II - 1 /* store into array of (signed) bytes */
castore 1 [C]II - 1 /* store into array of chars */
sastore 1 [S]II - 1 /* store into array of (signed) shorts*/
pop 1 1 - 1 /* pop top element */
pop2 1 2+1 - 1 /* pop top two elements */
dup 1 1 11 1 /* dup top element */
dup_x1 1 21 121 1 /* dup top element. Skip one */
dup_x2 1 3+21 1321 1 /* dup top element. Skip two */
dup2 1 2+1 2121 1 /* dup top two elements. */
dup2_x1 1 32+1 21321 1 /* dup top two elements. Skip one */
dup2_x2 1 4+32+1 214321 1 /* dup top two elements. Skip two */
swap 1 21 12 1 /* swap top two elements of stack. */
iadd 1 II I 1 /* integer add */
ladd 1 LL L 1 /* long add */
fadd 1 FF F 1 /* floating add */
dadd 1 DD D 1 /* double float add */
isub 1 II I 1 /* integer subtract */
lsub 1 LL L 1 /* long subtract */
fsub 1 FF F 1 /* floating subtract */
dsub 1 DD D 1 /* floating double subtract */
imul 1 II I 1 /* integer multiply */
lmul 1 LL L 1 /* long multiply */
fmul 1 FF F 1 /* floating multiply */
dmul 1 DD D 1 /* double float multiply */
idiv 1 II I 1 /* integer divide */
ldiv 1 LL L 1 /* long divide */
fdiv 1 FF F 1 /* floating divide */
ddiv 1 DD D 1 /* double float divide */
irem 1 II I 1 /* integer mod */
lrem 1 LL L 1 /* long mod */
frem 1 FF F 1 /* floating mod */
drem 1 DD D 1 /* double float mod */
ineg 1 I I 1 /* integer negate */
lneg 1 L L 1 /* long negate */
fneg 1 F F 1 /* floating negate */
dneg 1 D D 1 /* double float negate */
ishl 1 II I 1 /* shift left */
lshl 1 LI L 1 /* long shift left */
ishr 1 II I 1 /* shift right */
lshr 1 LI L 1 /* long shift right */
iushr 1 II I 1 /* unsigned shift right */
lushr 1 LI L 1 /* long unsigned shift right */
iand 1 II I 1 /* boolean and */
land 1 LL L 1 /* long boolean and */
ior 1 II I 1 /* boolean or */
lor 1 LL L 1 /* long boolean or */
ixor 1 II I 1 /* boolean xor */
lxor 1 LL L 1 /* long boolean xor */
iinc 3 - - 1 /* increment lcl variable by constant */
i2l 1 I L 1 /* integer to long */
i2f 1 I F 1 /* integer to float */
i2d 1 I D 1 /* integer to double */
l2i 1 L I 1 /* long to integer */
l2f 1 L F 1 /* long to float */
l2d 1 L D 1 /* long to double */
f2i 1 F I 1 /* float to integer */
f2l 1 F L 1 /* float to long */
f2d 1 F D 1 /* float to double */
d2i 1 D I 1 /* double to integer */
d2l 1 D L 1 /* double to long */
d2f 1 D F 1 /* double to float */
i2b 1 I I 1 /* integer to byte */
i2c 1 I I 1 /* integer to character */
i2s 1 I I 1 /* integer to signed short */
lcmp 1 LL I 1 /* long compare */
fcmpl 1 FF I 1 /* float compare. -1 on incomparable */
fcmpg 1 FF I 1 /* float compare. 1 on incomparable */
dcmpl 1 DD I 1 /* dbl floating cmp. -1 on incomp */
dcmpg 1 DD I 1 /* dbl floating cmp. 1 on incomp */
ifeq 3 I - 1 /* goto if equal */
ifne 3 I - 1 /* goto if not equal */
iflt 3 I - 1 /* goto if less than */
ifge 3 I - 1 /* goto if greater than or equal */
ifgt 3 I - 1 /* goto if greater than */
ifle 3 I - 1 /* goto if less than or equal */
if_icmpeq 3 II - 1 /* compare top two elements of stack */
if_icmpne 3 II - 1 /* compare top two elements of stack */
if_icmplt 3 II - 1 /* compare top two elements of stack */
if_icmpge 3 II - 1 /* compare top two elements of stack */
if_icmpgt 3 II - 1 /* compare top two elements of stack */
if_icmple 3 II - 1 /* compare top two elements of stack */
if_acmpeq 3 AA - 1 /* compare top two objects of stack */
if_acmpne 3 AA - 1 /* compare top two objects of stack */
goto 3 - - 1 /* unconditional goto */
jsr 3 - R 1 /* jump subroutine */
ret 2 - - 1 /* return from subroutine */
tableswitch 99 I - 1 /* goto (case) */
lookupswitch 99 I - 1 /* goto (case) */
ireturn 1 I - 1 /* return integer from procedure */
lreturn 1 L - 1 /* return long from procedure */
freturn 1 F - 1 /* return float from procedure */
dreturn 1 D - 1 /* return double from procedure */
areturn 1 A - 1 /* return object from procedure */
return 1 - - 1 /* return (void) from procedure */
getstatic 3 - ? 1 /* get static field value. */
putstatic 3 ? - 1 /* assign static field value */
getfield 3 A ? 1 /* get field value from object. */
putfield 3 ? - 1 /* assign field value to object. */
invokevirtual 3 ? ? 1 /* call method, based on object. */
invokespecial 3 ? ? 1 /* call method, not based on object. */
invokestatic 3 ? ? 1 /* call a static method. */
invokeinterface 5 ? ? 1 /* call an interface method */
xxxunusedxxx 0 ? ? 1 /* was newfromname */
new 3 - A 1 /* Create a new object */
newarray 2 I A 1 /* Create a new array of non-objects*/
anewarray 3 I A 1 /* Create a new array of objects */
arraylength 1 [?] I 1 /* get length of array */
athrow 1 O - 1 /* throw an exception */
checkcast 3 A A 1 /* error if object not of given type */
instanceof 3 A I 1 /* is object of given type? */
monitorenter 1 A - 1 /* enter a monitored region of code */
monitorexit 1 A - 1 /* exit a monitored region of code */
wide 0 - - 1 /* prefix operation. */
multianewarray 4 ? A 1 /* create multidimensional array */
ifnull 3 A - 1 /* goto if null */
ifnonnull 3 A - 1 /* goto if not null */
# The following instructions are "long" versions. They allow access to
# variables with index greater than 255.
goto_w 5 - - 1 /* unconditional goto. 4byte offset */
jsr_w 5 - R 1 /* jump subroutine. 4byte offset */
breakpoint 1 - - 1 /* call breakpoint handler */
# The compiler will not generate any of the following instructions. That
# are created by the interpreter from the non _quick versions of the
# instructions.
ldc_quick 2 - ? 1
ldc_w_quick 3 - ? 1
ldc2_w_quick 3 - ? 1
getfield_quick 3 A ? 1
putfield_quick 3 ? - 1
getfield2_quick 3 A ? 1
putfield2_quick 3 ? - 1
getstatic_quick 3 - ? 1
putstatic_quick 3 ? - 1
getstatic2_quick 3 - ? 1
putstatic2_quick 3 ? _ 1
invokevirtual_quick 3 ? ? 1
invokenonvirtual_quick 3 ? ? 1
invokesuper_quick 3 ? ? 1
invokestatic_quick 3 ? ? 1
invokeinterface_quick 5 ? ? 1
invokevirtualobject_quick 3 ? ? 1
invokeignored_quick 3 ? ? 1
new_quick 3 - A 1
anewarray_quick 3 I A 1
multianewarray_quick 4 ? A 1
checkcast_quick 3 A A 1
instanceof_quick 3 A I 1
# The following are generated when the offset is bigger than 255
invokevirtual_quick_w 3 ? ? 1
getfield_quick_w 3 A ? 1
putfield_quick_w 3 ? - 1
# used for simplification
nonnull_quick 1 A - 1 /* throw exception if stacktop null */

View file

@ -1,283 +0,0 @@
/*
* Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
char const opcode_weight[256] = {
1, /* nop */
1, /* aconst_null */
1, /* iconst_m1 */
1, /* iconst_0 */
1, /* iconst_1 */
1, /* iconst_2 */
1, /* iconst_3 */
1, /* iconst_4 */
1, /* iconst_5 */
1, /* lconst_0 */
1, /* lconst_1 */
1, /* fconst_0 */
1, /* fconst_1 */
1, /* fconst_2 */
1, /* dconst_0 */
1, /* dconst_1 */
1, /* bipush */
1, /* sipush */
1, /* ldc */
1, /* ldc_w */
1, /* ldc2_w */
1, /* iload */
1, /* lload */
1, /* fload */
1, /* dload */
1, /* aload */
1, /* iload_0 */
1, /* iload_1 */
1, /* iload_2 */
1, /* iload_3 */
1, /* lload_0 */
1, /* lload_1 */
1, /* lload_2 */
1, /* lload_3 */
1, /* fload_0 */
1, /* fload_1 */
1, /* fload_2 */
1, /* fload_3 */
1, /* dload_0 */
1, /* dload_1 */
1, /* dload_2 */
1, /* dload_3 */
1, /* aload_0 */
1, /* aload_1 */
1, /* aload_2 */
1, /* aload_3 */
1, /* iaload */
1, /* laload */
1, /* faload */
1, /* daload */
1, /* aaload */
1, /* baload */
1, /* caload */
1, /* saload */
1, /* istore */
1, /* lstore */
1, /* fstore */
1, /* dstore */
1, /* astore */
1, /* istore_0 */
1, /* istore_1 */
1, /* istore_2 */
1, /* istore_3 */
1, /* lstore_0 */
1, /* lstore_1 */
1, /* lstore_2 */
1, /* lstore_3 */
1, /* fstore_0 */
1, /* fstore_1 */
1, /* fstore_2 */
1, /* fstore_3 */
1, /* dstore_0 */
1, /* dstore_1 */
1, /* dstore_2 */
1, /* dstore_3 */
1, /* astore_0 */
1, /* astore_1 */
1, /* astore_2 */
1, /* astore_3 */
1, /* iastore */
1, /* lastore */
1, /* fastore */
1, /* dastore */
1, /* aastore */
1, /* bastore */
1, /* castore */
1, /* sastore */
1, /* pop */
1, /* pop2 */
1, /* dup */
1, /* dup_x1 */
1, /* dup_x2 */
1, /* dup2 */
1, /* dup2_x1 */
1, /* dup2_x2 */
1, /* swap */
1, /* iadd */
1, /* ladd */
1, /* fadd */
1, /* dadd */
1, /* isub */
1, /* lsub */
1, /* fsub */
1, /* dsub */
1, /* imul */
1, /* lmul */
1, /* fmul */
1, /* dmul */
1, /* idiv */
1, /* ldiv */
1, /* fdiv */
1, /* ddiv */
1, /* irem */
1, /* lrem */
1, /* frem */
1, /* drem */
1, /* ineg */
1, /* lneg */
1, /* fneg */
1, /* dneg */
1, /* ishl */
1, /* lshl */
1, /* ishr */
1, /* lshr */
1, /* iushr */
1, /* lushr */
1, /* iand */
1, /* land */
1, /* ior */
1, /* lor */
1, /* ixor */
1, /* lxor */
1, /* iinc */
1, /* i2l */
1, /* i2f */
1, /* i2d */
1, /* l2i */
1, /* l2f */
1, /* l2d */
1, /* f2i */
1, /* f2l */
1, /* f2d */
1, /* d2i */
1, /* d2l */
1, /* d2f */
1, /* i2b */
1, /* i2c */
1, /* i2s */
1, /* lcmp */
1, /* fcmpl */
1, /* fcmpg */
1, /* dcmpl */
1, /* dcmpg */
1, /* ifeq */
1, /* ifne */
1, /* iflt */
1, /* ifge */
1, /* ifgt */
1, /* ifle */
1, /* if_icmpeq */
1, /* if_icmpne */
1, /* if_icmplt */
1, /* if_icmpge */
1, /* if_icmpgt */
1, /* if_icmple */
1, /* if_acmpeq */
1, /* if_acmpne */
1, /* goto */
1, /* jsr */
1, /* ret */
1, /* tableswitch */
1, /* lookupswitch */
1, /* ireturn */
1, /* lreturn */
1, /* freturn */
1, /* dreturn */
1, /* areturn */
1, /* return */
1, /* getstatic */
1, /* putstatic */
1, /* getfield */
1, /* putfield */
1, /* invokevirtual */
1, /* invokespecial */
1, /* invokestatic */
1, /* invokeinterface */
1, /* xxxunusedxxx */
1, /* new */
1, /* newarray */
1, /* anewarray */
1, /* arraylength */
1, /* athrow */
1, /* checkcast */
1, /* instanceof */
1, /* monitorenter */
1, /* monitorexit */
1, /* wide */
1, /* multianewarray */
1, /* ifnull */
1, /* ifnonnull */
1, /* goto_w */
1, /* jsr_w */
1, /* breakpoint */
1, /* ldc_quick */
1, /* ldc_w_quick */
1, /* ldc2_w_quick */
1, /* getfield_quick */
1, /* putfield_quick */
1, /* getfield2_quick */
1, /* putfield2_quick */
1, /* getstatic_quick */
1, /* putstatic_quick */
1, /* getstatic2_quick */
1, /* putstatic2_quick */
1, /* invokevirtual_quick */
1, /* invokenonvirtual_quick */
1, /* invokesuper_quick */
1, /* invokestatic_quick */
1, /* invokeinterface_quick */
1, /* invokevirtualobject_quick */
1, /* invokeignored_quick */
1, /* new_quick */
1, /* anewarray_quick */
1, /* multianewarray_quick */
1, /* checkcast_quick */
1, /* instanceof_quick */
1, /* invokevirtual_quick_w */
1, /* getfield_quick_w */
1, /* putfield_quick_w */
1, /* nonnull_quick */
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

View file

@ -1,256 +0,0 @@
NoWideOpcode(nop)
NoWideOpcode(aconst_null)
NoWideOpcode(iconst_m1)
NoWideOpcode(iconst_0)
NoWideOpcode(iconst_1)
NoWideOpcode(iconst_2)
NoWideOpcode(iconst_3)
NoWideOpcode(iconst_4)
NoWideOpcode(iconst_5)
NoWideOpcode(lconst_0)
NoWideOpcode(lconst_1)
NoWideOpcode(fconst_0)
NoWideOpcode(fconst_1)
NoWideOpcode(fconst_2)
NoWideOpcode(dconst_0)
NoWideOpcode(dconst_1)
NoWideOpcode(bipush)
NoWideOpcode(sipush)
NoWideOpcode(ldc)
NoWideOpcode(ldc_w)
NoWideOpcode(ldc2_w)
WideOpcode(iload)
WideOpcode(lload)
WideOpcode(fload)
WideOpcode(dload)
WideOpcode(aload)
NoWideOpcode(iload_0)
NoWideOpcode(iload_1)
NoWideOpcode(iload_2)
NoWideOpcode(iload_3)
NoWideOpcode(lload_0)
NoWideOpcode(lload_1)
NoWideOpcode(lload_2)
NoWideOpcode(lload_3)
NoWideOpcode(fload_0)
NoWideOpcode(fload_1)
NoWideOpcode(fload_2)
NoWideOpcode(fload_3)
NoWideOpcode(dload_0)
NoWideOpcode(dload_1)
NoWideOpcode(dload_2)
NoWideOpcode(dload_3)
NoWideOpcode(aload_0)
NoWideOpcode(aload_1)
NoWideOpcode(aload_2)
NoWideOpcode(aload_3)
NoWideOpcode(iaload)
NoWideOpcode(laload)
NoWideOpcode(faload)
NoWideOpcode(daload)
NoWideOpcode(aaload)
NoWideOpcode(baload)
NoWideOpcode(caload)
NoWideOpcode(saload)
WideOpcode(istore)
WideOpcode(lstore)
WideOpcode(fstore)
WideOpcode(dstore)
WideOpcode(astore)
NoWideOpcode(istore_0)
NoWideOpcode(istore_1)
NoWideOpcode(istore_2)
NoWideOpcode(istore_3)
NoWideOpcode(lstore_0)
NoWideOpcode(lstore_1)
NoWideOpcode(lstore_2)
NoWideOpcode(lstore_3)
NoWideOpcode(fstore_0)
NoWideOpcode(fstore_1)
NoWideOpcode(fstore_2)
NoWideOpcode(fstore_3)
NoWideOpcode(dstore_0)
NoWideOpcode(dstore_1)
NoWideOpcode(dstore_2)
NoWideOpcode(dstore_3)
NoWideOpcode(astore_0)
NoWideOpcode(astore_1)
NoWideOpcode(astore_2)
NoWideOpcode(astore_3)
NoWideOpcode(iastore)
NoWideOpcode(lastore)
NoWideOpcode(fastore)
NoWideOpcode(dastore)
NoWideOpcode(aastore)
NoWideOpcode(bastore)
NoWideOpcode(castore)
NoWideOpcode(sastore)
NoWideOpcode(pop)
NoWideOpcode(pop2)
NoWideOpcode(dup)
NoWideOpcode(dup_x1)
NoWideOpcode(dup_x2)
NoWideOpcode(dup2)
NoWideOpcode(dup2_x1)
NoWideOpcode(dup2_x2)
NoWideOpcode(swap)
NoWideOpcode(iadd)
NoWideOpcode(ladd)
NoWideOpcode(fadd)
NoWideOpcode(dadd)
NoWideOpcode(isub)
NoWideOpcode(lsub)
NoWideOpcode(fsub)
NoWideOpcode(dsub)
NoWideOpcode(imul)
NoWideOpcode(lmul)
NoWideOpcode(fmul)
NoWideOpcode(dmul)
NoWideOpcode(idiv)
NoWideOpcode(ldiv)
NoWideOpcode(fdiv)
NoWideOpcode(ddiv)
NoWideOpcode(irem)
NoWideOpcode(lrem)
NoWideOpcode(frem)
NoWideOpcode(drem)
NoWideOpcode(ineg)
NoWideOpcode(lneg)
NoWideOpcode(fneg)
NoWideOpcode(dneg)
NoWideOpcode(ishl)
NoWideOpcode(lshl)
NoWideOpcode(ishr)
NoWideOpcode(lshr)
NoWideOpcode(iushr)
NoWideOpcode(lushr)
NoWideOpcode(iand)
NoWideOpcode(land)
NoWideOpcode(ior)
NoWideOpcode(lor)
NoWideOpcode(ixor)
NoWideOpcode(lxor)
WideOpcode(iinc)
NoWideOpcode(i2l)
NoWideOpcode(i2f)
NoWideOpcode(i2d)
NoWideOpcode(l2i)
NoWideOpcode(l2f)
NoWideOpcode(l2d)
NoWideOpcode(f2i)
NoWideOpcode(f2l)
NoWideOpcode(f2d)
NoWideOpcode(d2i)
NoWideOpcode(d2l)
NoWideOpcode(d2f)
NoWideOpcode(i2b)
NoWideOpcode(i2c)
NoWideOpcode(i2s)
NoWideOpcode(lcmp)
NoWideOpcode(fcmpl)
NoWideOpcode(fcmpg)
NoWideOpcode(dcmpl)
NoWideOpcode(dcmpg)
NoWideOpcode(ifeq)
NoWideOpcode(ifne)
NoWideOpcode(iflt)
NoWideOpcode(ifge)
NoWideOpcode(ifgt)
NoWideOpcode(ifle)
NoWideOpcode(if_icmpeq)
NoWideOpcode(if_icmpne)
NoWideOpcode(if_icmplt)
NoWideOpcode(if_icmpge)
NoWideOpcode(if_icmpgt)
NoWideOpcode(if_icmple)
NoWideOpcode(if_acmpeq)
NoWideOpcode(if_acmpne)
NoWideOpcode(goto)
NoWideOpcode(jsr)
WideOpcode(ret)
NoWideOpcode(tableswitch)
NoWideOpcode(lookupswitch)
NoWideOpcode(ireturn)
NoWideOpcode(lreturn)
NoWideOpcode(freturn)
NoWideOpcode(dreturn)
NoWideOpcode(areturn)
NoWideOpcode(return)
NoWideOpcode(getstatic)
NoWideOpcode(putstatic)
NoWideOpcode(getfield)
NoWideOpcode(putfield)
NoWideOpcode(invokevirtual)
NoWideOpcode(invokespecial)
NoWideOpcode(invokestatic)
NoWideOpcode(invokeinterface)
NoWideOpcode(xxxunusedxxx)
NoWideOpcode(new)
NoWideOpcode(newarray)
NoWideOpcode(anewarray)
NoWideOpcode(arraylength)
NoWideOpcode(athrow)
NoWideOpcode(checkcast)
NoWideOpcode(instanceof)
NoWideOpcode(monitorenter)
NoWideOpcode(monitorexit)
NoWideOpcode(wide)
NoWideOpcode(multianewarray)
NoWideOpcode(ifnull)
NoWideOpcode(ifnonnull)
NoWideOpcode(goto_w)
NoWideOpcode(jsr_w)
NoWideOpcode(breakpoint)
NoWideOpcode(ldc_quick)
NoWideOpcode(ldc_w_quick)
NoWideOpcode(ldc2_w_quick)
NoWideOpcode(getfield_quick)
NoWideOpcode(putfield_quick)
NoWideOpcode(getfield2_quick)
NoWideOpcode(putfield2_quick)
NoWideOpcode(getstatic_quick)
NoWideOpcode(putstatic_quick)
NoWideOpcode(getstatic2_quick)
NoWideOpcode(putstatic2_quick)
NoWideOpcode(invokevirtual_quick)
NoWideOpcode(invokenonvirtual_quick)
NoWideOpcode(invokesuper_quick)
NoWideOpcode(invokestatic_quick)
NoWideOpcode(invokeinterface_quick)
NoWideOpcode(invokevirtualobject_quick)
NoWideOpcode(invokeignored_quick)
NoWideOpcode(new_quick)
NoWideOpcode(anewarray_quick)
NoWideOpcode(multianewarray_quick)
NoWideOpcode(checkcast_quick)
NoWideOpcode(instanceof_quick)
NoWideOpcode(invokevirtual_quick_w)
NoWideOpcode(getfield_quick_w)
NoWideOpcode(putfield_quick_w)
NoWideOpcode(nonnull_quick)
NoWideOpcode(Illegal230)
NoWideOpcode(Illegal231)
NoWideOpcode(Illegal232)
NoWideOpcode(Illegal233)
NoWideOpcode(Illegal234)
NoWideOpcode(Illegal235)
NoWideOpcode(Illegal236)
NoWideOpcode(Illegal237)
NoWideOpcode(Illegal238)
NoWideOpcode(Illegal239)
NoWideOpcode(Illegal240)
NoWideOpcode(Illegal241)
NoWideOpcode(Illegal242)
NoWideOpcode(Illegal243)
NoWideOpcode(Illegal244)
NoWideOpcode(Illegal245)
NoWideOpcode(Illegal246)
NoWideOpcode(Illegal247)
NoWideOpcode(Illegal248)
NoWideOpcode(Illegal249)
NoWideOpcode(Illegal250)
NoWideOpcode(Illegal251)
NoWideOpcode(Illegal252)
NoWideOpcode(Illegal253)
NoWideOpcode(Illegal254)
NoWideOpcode(Illegal255)

View file

@ -1,178 +0,0 @@
/*
* Copyright 1994-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _JAVASOFT_SYS_API_H_
#define _JAVASOFT_SYS_API_H_
#include "hpi.h"
extern HPI_MemoryInterface *hpi_memory_interface;
extern HPI_LibraryInterface *hpi_library_interface;
extern HPI_SystemInterface *hpi_system_interface;
extern HPI_ThreadInterface *hpi_thread_interface;
extern HPI_FileInterface *hpi_file_interface;
extern HPI_SocketInterface *hpi_socket_interface;
#define sysMalloc(x) hpi_memory_interface->Malloc(x)
#define sysRealloc(x,y) hpi_memory_interface->Realloc(x,y)
#define sysFree(x) hpi_memory_interface->Free(x)
#define sysCalloc(x,y) hpi_memory_interface->Calloc(x,y)
#define sysStrdup(x) hpi_memory_interface->Strdup(x)
#define sysMapMem(x,y) hpi_memory_interface->MapMem(x,y)
#define sysUnmapMem(x,y,z) hpi_memory_interface->UnmapMem(x,y,z)
#define sysCommitMem(x,y,z) hpi_memory_interface->CommitMem(x,y,z)
#define sysDecommitMem(x,y,z) hpi_memory_interface->DecommitMem(x,y,z)
#define sysAllocBlock(x,y) hpi_memory_interface->AllocBlock(x,y)
#define sysFreeBlock(x) hpi_memory_interface->FreeBlock(x)
#define sysBuildLibName(a,b,c,d) hpi_library_interface->BuildLibName(a,b,c,d)
#define sysBuildFunName(a,b,c,d) hpi_library_interface->BuildFunName(a,b,c,d)
#define sysLoadLibrary(a,b,c) hpi_library_interface->LoadLibrary(a,b,c)
#define sysUnloadLibrary(a) hpi_library_interface->UnloadLibrary(a)
#define sysFindLibraryEntry(a,b) hpi_library_interface->FindLibraryEntry(a,b)
#define sysGetSysInfo() hpi_system_interface->GetSysInfo()
#define sysGetMilliTicks() hpi_system_interface->GetMilliTicks()
#define sysTimeMillis() hpi_system_interface->TimeMillis()
#define sysSignal(a,b) hpi_system_interface->Signal(a,b)
#define sysRaise(a) hpi_system_interface->Raise(a)
#define sysSignalNotify(a) hpi_system_interface->SignalNotify(a)
#define sysSignalWait() hpi_system_interface->SignalWait()
#define sysShutdown() hpi_system_interface->Shutdown()
#define sysSetLoggingLevel(a) hpi_system_interface->SetLoggingLevel(a)
#define sysSetMonitoringOn(a) hpi_system_interface->SetMonitoringOn(a)
#define sysGetLastErrorString(a,b) hpi_system_interface->GetLastErrorString(a,b)
#define sysThreadBootstrap(a,b,c) hpi_thread_interface->ThreadBootstrap(a,b,c)
#define sysThreadCreate(a,b,c,d) hpi_thread_interface->ThreadCreate(a,b,c,d)
#define sysThreadSelf() hpi_thread_interface->ThreadSelf()
#define sysThreadYield() hpi_thread_interface->ThreadYield()
#define sysThreadSuspend(a) hpi_thread_interface->ThreadSuspend(a)
#define sysThreadResume(a) hpi_thread_interface->ThreadResume(a)
#define sysThreadSetPriority(a,b) hpi_thread_interface->ThreadSetPriority(a,b)
#define sysThreadGetPriority(a,b) hpi_thread_interface->ThreadGetPriority(a,b)
#define sysThreadStackPointer(a) hpi_thread_interface->ThreadStackPointer(a)
#define sysThreadStackTop(a) hpi_thread_interface->ThreadStackTop(a)
#define sysThreadRegs(a,b) hpi_thread_interface->ThreadRegs(a,b)
#define sysThreadSingle() hpi_thread_interface->ThreadSingle()
#define sysThreadMulti() hpi_thread_interface->ThreadMulti()
#define sysThreadCheckStack() hpi_thread_interface->ThreadCheckStack()
#define sysThreadPostException(a,b) \
hpi_thread_interface->ThreadPostException(a,b)
#define sysThreadInterrupt(a) hpi_thread_interface->ThreadInterrupt(a)
#define sysThreadIsInterrupted(a,b) \
hpi_thread_interface->ThreadIsInterrupted(a,b)
#define sysThreadAlloc(a) hpi_thread_interface->ThreadAlloc(a)
#define sysThreadFree() hpi_thread_interface->ThreadFree()
#define sysThreadCPUTime() hpi_thread_interface->ThreadCPUTime()
#define sysThreadGetStatus(a,b) hpi_thread_interface->ThreadGetStatus(a,b)
#define sysThreadEnumerateOver(a,b) \
hpi_thread_interface->ThreadEnumerateOver(a,b)
#define sysThreadIsRunning(a) hpi_thread_interface->ThreadIsRunning(a)
#define sysThreadProfSuspend(a) hpi_thread_interface->ThreadProfSuspend(a)
#define sysThreadProfResume(a) hpi_thread_interface->ThreadProfResume(a)
#define sysAdjustTimeSlice(a) hpi_thread_interface->AdjustTimeSlice(a)
#define sysMonitorSizeof() hpi_thread_interface->MonitorSizeof()
#define sysMonitorInit(a) hpi_thread_interface->MonitorInit(a)
#define sysMonitorDestroy(a) hpi_thread_interface->MonitorDestroy(a)
#define sysMonitorEnter(a,b) hpi_thread_interface->MonitorEnter(a,b)
#define sysMonitorEntered(a,b) hpi_thread_interface->MonitorEntered(a,b)
#define sysMonitorExit(a,b) hpi_thread_interface->MonitorExit(a,b)
#define sysMonitorNotify(a,b) hpi_thread_interface->MonitorNotify(a,b)
#define sysMonitorNotifyAll(a,b) hpi_thread_interface->MonitorNotifyAll(a,b)
#define sysMonitorWait(a,b,c) hpi_thread_interface->MonitorWait(a,b,c)
#define sysMonitorInUse(a) hpi_thread_interface->MonitorInUse(a)
#define sysMonitorOwner(a) hpi_thread_interface->MonitorOwner(a)
#define sysMonitorGetInfo(a,b) hpi_thread_interface->MonitorGetInfo(a,b)
#define sysThreadInterruptEvent() hpi_thread_interface->ThreadInterruptEvent()
#define sysThreadNativeID(a) hpi_thread_interface->ThreadNativeID(a)
#define sysNativePath(a) hpi_file_interface->NativePath(a)
#define sysFileType(a) hpi_file_interface->FileType(a)
#define sysOpen(a,b,c) hpi_file_interface->Open(a,b,c)
#define sysClose(a) hpi_file_interface->Close(a)
#define sysSeek(a,b,c) hpi_file_interface->Seek(a,b,c)
#define sysSetLength(a,b) hpi_file_interface->SetLength(a,b)
#define sysSync(a) hpi_file_interface->Sync(a)
#define sysAvailable(a,b) hpi_file_interface->Available(a,b)
#define sysRead(a,b,c) hpi_file_interface->Read(a,b,c)
#define sysWrite(a,b,c) hpi_file_interface->Write(a,b,c)
#define sysFileSizeFD(a,b) hpi_file_interface->FileSizeFD(a,b)
#define sysSocketClose(a) hpi_socket_interface->Close(a)
#define sysSocketShutdown(a,b) hpi_socket_interface->SocketShutdown(a,b)
#define sysSocketAvailable(a,b) hpi_socket_interface->Available(a,b)
#define sysConnect(a,b,c) hpi_socket_interface->Connect(a,b,c)
#define sysBind(a,b,c) hpi_socket_interface->Bind(a,b,c)
#define sysAccept(a,b,c) hpi_socket_interface->Accept(a,b,c)
#define sysGetSockName(a,b,c) hpi_socket_interface->GetSocketName(a,b,c)
#define sysSendTo(a,b,c,d,e,f) hpi_socket_interface->SendTo(a,b,c,d,e,f)
#define sysRecvFrom(a,b,c,d,e,f) hpi_socket_interface->RecvFrom(a,b,c,d,e,f)
#define sysListen(a,b) hpi_socket_interface->Listen(a,b)
#define sysRecv(a,b,c,d) hpi_socket_interface->Recv(a,b,c,d)
#define sysSend(a,b,c,d) hpi_socket_interface->Send(a,b,c,d)
#define sysTimeout(a,b) hpi_socket_interface->Timeout(a,b)
#define sysGetHostName(a, b) hpi_socket_interface->GetHostName(a, b)
#define sysGetHostByAddr(a, b, c) hpi_socket_interface->GetHostByAddr(a, b, c)
#define sysGetHostByName(a) hpi_socket_interface->GetHostByName(a)
#define sysSocket(a,b,c) hpi_socket_interface->Socket(a,b,c)
#define sysGetSockOpt(a, b, c, d, e) hpi_socket_interface->SocketGetOption(a, b, c, d, e)
#define sysSetSockOpt(a, b, c, d, e) hpi_socket_interface->SocketSetOption(a, b, c, d, e)
#define sysGetProtoByName(a) hpi_socket_interface->GetProtoByName(a)
#define SYS_SIG_DFL HPI_SIG_DFL
#define SYS_SIG_ERR HPI_SIG_ERR
#define SYS_SIG_IGN HPI_SIG_IGN
#define SYS_OK HPI_OK
#define SYS_ERR HPI_ERR
#define SYS_INTRPT HPI_INTRPT
#define SYS_TIMEOUT HPI_TIMEOUT
#define SYS_NOMEM HPI_NOMEM
#define SYS_NORESOURCE HPI_NORESOURCE
#define SYS_THREAD_RUNNABLE HPI_THREAD_RUNNABLE
#define SYS_THREAD_MONITOR_WAIT HPI_THREAD_MONITOR_WAIT
#define SYS_THREAD_CONDVAR_WAIT HPI_THREAD_CONDVAR_WAIT
#define MinimumPriority HPI_MINIMUM_PRIORITY
#define MaximumPriority HPI_MAXIMUM_PRIORITY
#define NormalPriority HPI_NORMAL_PRIORITY
#define SYS_THREAD_SUSPENDED HPI_THREAD_SUSPENDED
#define SYS_THREAD_INTERRUPTED HPI_THREAD_INTERRUPTED
#define PAGE_ALIGNMENT HPI_PAGE_ALIGNMENT
#define SYS_TIMEOUT_INFINITY HPI_TIMEOUT_INFINITY
#define SYS_FILETYPE_REGULAR HPI_FILETYPE_REGULAR
#define SYS_FILETYPE_DIRECTORY HPI_FILETYPE_DIRECTORY
#define SYS_FILETYPE_OTHER HPI_FILETYPE_OTHER
#endif /* !_JAVASOFT_SYS_API_H_ */

View file

@ -1,120 +0,0 @@
/*
* Copyright 1994-2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
#ifndef _JAVASOFT_TYPEDEFS_H_
#define _JAVASOFT_TYPEDEFS_H_
#include "typedefs_md.h" /* for int64_t */
/*
* Macros to deal with the JavaVM's stack alignment. Many machines
* require doublewords to be double aligned. This union is used by
* code in math.h as a more portable way do alingnment on machines
* that require it. This union and the macros that use it came from
* Netscape.
*/
#ifdef HAVE_ALIGNED_LONGLONGS
#define GET_INT64(_t,_addr) \
((((int32_t*) &(_t))[0] = ((int32_t*)(_addr))[0]), \
(((int32_t*) &(_t))[1] = ((int32_t*)(_addr))[1]), \
(_t).j )
#define SET_INT64(_t, _addr, _v) \
( (_t).j = (_v), \
((int32_t*)(_addr))[0] = ((int32_t*) &(_t))[0], \
((int32_t*)(_addr))[1] = ((int32_t*) &(_t))[1] )
#else
#define GET_INT64(_t,_addr) (*(int64_t*)(_addr))
#define SET_INT64(_t, _addr, _v) (*(int64_t*)(_addr) = (_v))
#endif
/* If double's must be aligned on doubleword boundaries then define this */
#ifdef HAVE_ALIGNED_DOUBLES
#define GET_DOUBLE(_t,_addr) \
((((int32_t*) &(_t))[0] = ((int32_t*)(_addr))[0]), \
(((int32_t*) &(_t))[1] = ((int32_t*)(_addr))[1]), \
(_t).d )
#define SET_DOUBLE(_t, _addr, _v) \
( (_t).d = (_v), \
((int32_t*)(_addr))[0] = ((int32_t*) &(_t))[0], \
((int32_t*)(_addr))[1] = ((int32_t*) &(_t))[1] )
#else
#define GET_DOUBLE(_t,_addr) (*(jdouble*)(_addr))
#define SET_DOUBLE(_t, _addr, _v) (*(jdouble*)(_addr) = (_v))
#endif
/* If pointers are 64bits then define this */
#ifdef HAVE_64BIT_POINTERS
#define GET_HANDLE(_t,_addr) \
( ((int32_t*) &(_t))[0] = ((int32_t*)(_addr))[0]), \
((int32_t*) &(_t))[1] = ((int32_t*)(_addr))[1]), \
(void*) (_t).l )
#define SET_HANDLE(_t, _addr, _v) \
( *(void**) &((_t).l) = (_v), \
((int32_t*)(_addr))[0] = ((int32_t*) &(_t))[0], \
((int32_t*)(_addr))[1] = ((int32_t*) &(_t))[1] )
#else
#define GET_HANDLE(_t,_addr) (*(JHandle*)(_addr))
#define SET_HANDLE(_t, _addr, _v) (*(JHandle*)(_addr) = (_v))
#endif
/*
* Printf-style formatters for fixed- and variable-width types as pointers and
* integers.
*
* Each platform-specific definitions file "typedefs_md.h"
* must define the macro FORMAT64_MODIFIER, which is the modifier for '%x' or
* '%d' formats to indicate a 64-bit quantity; commonly "l" (in LP64) or "ll"
* (in ILP32).
*/
/* Format 32-bit quantities. */
#define INT32_FORMAT "%d"
#define UINT32_FORMAT "%u"
#define PTR32_FORMAT "0x%08x"
/* Format 64-bit quantities. */
#define INT64_FORMAT "%" FORMAT64_MODIFIER "d"
#define UINT64_FORMAT "%" FORMAT64_MODIFIER "u"
#define PTR64_FORMAT "0x%016" FORMAT64_MODIFIER "x"
/* Format pointers and size_t (or size_t-like integer types) which change size
* between 32- and 64-bit.
*/
#if defined(_LP64) || defined(_WIN64)
#define PTR_FORMAT PTR64_FORMAT
#define SIZE_FORMAT UINT64_FORMAT
#define SSIZE_FORMAT INT64_FORMAT
#else
#define PTR_FORMAT PTR32_FORMAT
#define SIZE_FORMAT UINT32_FORMAT
#define SSIZE_FORMAT INT32_FORMAT
#endif
#define INTPTR_FORMAT PTR_FORMAT
#endif /* !_JAVASOFT_TYPEDEFS_H_ */

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -246,7 +246,7 @@ VerifyClassname(char *name, jboolean allowArrayClass)
/* skip over the fieldname. Slashes are okay */ /* skip over the fieldname. Slashes are okay */
p = skip_over_fieldname(name, JNI_TRUE, length); p = skip_over_fieldname(name, JNI_TRUE, length);
} }
return (p != 0 && p - name == length); return (p != 0 && p - name == (ptrdiff_t)length);
} }
/* /*

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,9 @@
#ifndef JDWP_UTIL_MD_H #ifndef JDWP_UTIL_MD_H
#define JDWP_UTIL_MD_H #define JDWP_UTIL_MD_H
#include <stddef.h>
#include <stdint.h> /* To get uintptr_t */
#include <limits.h> #include <limits.h>
#include <sys/types.h> #include <sys/types.h>

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,5 +23,8 @@
* have any questions. * have any questions.
*/ */
#include <stddef.h>
#include <stdint.h> /* For uintprt_t */
#include <stdlib.h> #include <stdlib.h>
#include <sys/param.h> /* For MAXPATHLEN */ #include <sys/param.h> /* For MAXPATHLEN */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,6 +34,8 @@
#include <dirent.h> /* For DIR */ #include <dirent.h> /* For DIR */
#include <sys/param.h> /* For MAXPATHLEN */ #include <sys/param.h> /* For MAXPATHLEN */
#include <unistd.h> /* For F_OK, R_OK, W_OK */ #include <unistd.h> /* For F_OK, R_OK, W_OK */
#include <stddef.h> /* For ptrdiff_t */
#include <stdint.h> /* For uintptr_t */
#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"} #define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"}
#define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"} #define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"}

View file

@ -1,174 +0,0 @@
/*
* Copyright 1994-2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* Solaris-dependent types for Green threads
*/
#ifndef _JAVASOFT_SOLARIS_TYPES_MD_H_
#define _JAVASOFT_SOLARIS_TYPES_MD_H_
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __linux__
#include <stdint.h>
#define HAVE_INTPTR_T
#define _UINT64_T
#endif
#define int8_t char
/* Fix for varargs differences on PowerPC */
#if defined(__powerpc__)
#define VARGS(x) (x)
#else
#define VARGS(x) (&x)
#endif /* __powerpc__ */
#if defined(__alpha__)
#define PTR_IS_64 1
#define LONG_IS_64 1
#else
#define PTR_IS_32 1
#endif
/* don't redefine typedef's on Solaris 2.6 or Later */
#if !defined(_ILP32) && !defined(_LP64)
#ifndef HAVE_INTPTR_T
#ifdef LONG_IS_64
typedef long intptr_t;
typedef unsigned long uintptr_t;
#else
typedef int intptr_t;
typedef unsigned int uintptr_t;
#endif /* LONG_IS_64 */
#endif /* don't HAVE_INTPTR_T */
#ifndef _UINT64_T
#define _UINT64_T
#ifdef LONG_IS_64
typedef unsigned long uint64_t;
#else
typedef unsigned long long uint64_t;
#endif
#define _UINT32_T
#ifndef uint32_t /* [sbb] scaffolding */
typedef unsigned int uint32_t;
#endif /* [sbb] scaffolding */
#if defined(__linux__)
typedef unsigned int uint_t;
#endif
#endif
#ifndef __BIT_TYPES_DEFINED__
/* that should get Linux, at least */
#ifndef _INT64_T
#define _INT64_T
#ifdef LONG_IS_64
typedef long int64_t;
#else
typedef long long int64_t;
#endif
#define _INT32_T
#ifndef int32_t /* [sbb] scaffolding */
typedef int int32_t;
#endif /* [sbb] scaffolding */
#if defined(__linux__)
typedef int int_t;
#endif
#endif
#endif /* __BIT_TYPES_DEFINED__ */
#endif /* !defined(_ILP32) && !defined(_LP64) */
/* use these macros when the compiler supports the long long type */
#define ll_high(a) ((uint32_t)(((uint64_t)(a))>>32))
#define ll_low(a) ((uint32_t)(a))
#define int2ll(a) ((int64_t)(a))
#define ll2int(a) ((int)(a))
#define ll_add(a, b) ((int64_t)(a) + (int64_t)(b))
#define ll_and(a, b) ((int64_t)(a) & (int64_t)(b))
#define ll_div(a, b) ((int64_t)(a) / (int64_t)(b))
#define ll_mul(a, b) ((int64_t)(a) * (int64_t)(b))
#define ll_neg(a) (-(a))
#define ll_not(a) (~(uint64_t)(a))
#define ll_or(a, b) ((uint64_t)(a) | (b))
#define ll_shl(a, n) ((uint64_t)(a) << (n))
#define ll_shr(a, n) ((int64_t)(a) >> (n))
#define ll_sub(a, b) ((uint64_t)(a) - (b))
#define ll_ushr(a, n) ((uint64_t)(a) >>(n))
#define ll_xor(a, b) ((int64_t)(a) ^ (int64_t)(b))
#define uint2ll(a) ((uint64_t)(a))
#define ll_rem(a,b) ((int64_t)(a) % (int64_t)(b))
extern int32_t float2l(float f);
extern int32_t double2l(double d);
extern int64_t float2ll(float f);
extern int64_t double2ll(double d);
#define ll2float(a) ((float) (a))
#define ll2double(a) ((double) (a))
/* Useful on machines where jlong and jdouble have different endianness. */
#define ll2double_bits(a) ((void) 0)
/* comparison operators */
#define ll_ltz(ll) ((ll)<0)
#define ll_gez(ll) ((ll)>=0)
#define ll_eqz(a) ((a) == 0)
#define ll_nez(a) ((a) != 0)
#define ll_eq(a, b) ((a) == (b))
#define ll_ne(a,b) ((a) != (b))
#define ll_ge(a,b) ((a) >= (b))
#define ll_le(a,b) ((a) <= (b))
#define ll_lt(a,b) ((a) < (b))
#define ll_gt(a,b) ((a) > (b))
#define ll_zero_const ((int64_t) 0)
#define ll_one_const ((int64_t) 1)
extern void ll2str(int64_t a, char *s, char *limit);
#define ll2ptr(a) ((void*)(uintptr_t)(a))
#define ptr2ll(a) ((int64_t)(uintptr_t)(a))
#ifdef ppc
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#endif
/* printf format modifier for printing pointers */
#ifdef _LP64
#define FORMAT64_MODIFIER "l"
#else
#define FORMAT64_MODIFIER "ll"
#endif
#endif /* !_JAVASOFT_SOLARIS_TYPES_MD_H_ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,15 +24,12 @@
*/ */
/* /*
* Solaris dependent type definitions includes intptr_t, etc * Solaris/Linux dependent type definitions includes intptr_t, etc
*/ */
#include <stddef.h>
#include <stdint.h> /* For uintptr_t */
#include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
/*
* Linux version of <sys/types.h> does not define intptr_t
*/
#ifdef __linux__
#include <stdint.h>
#include <malloc.h>
#endif /* __linux__ */

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,7 @@
/* Make sure ptrdiff_t is defined */ /* Make sure ptrdiff_t is defined */
#include <stddef.h> #include <stddef.h>
#include "typedefs.h" #include <stdint.h> /* For uintptr_t */
#define jlong_high(a) ((jint)((a)>>32)) #define jlong_high(a) ((jint)((a)>>32))
#define jlong_low(a) ((jint)(a)) #define jlong_low(a) ((jint)(a))

View file

@ -206,10 +206,10 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
/* /*
* Class: java_net_NetworkInterface * Class: java_net_NetworkInterface
* Method: getByIndex * Method: getByIndex0
* Signature: (Ljava/lang/String;)Ljava/net/NetworkInterface; * Signature: (Ljava/lang/String;)Ljava/net/NetworkInterface;
*/ */
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0
(JNIEnv *env, jclass cls, jint index) { (JNIEnv *env, jclass cls, jint index) {
netif *ifs, *curr; netif *ifs, *curr;

View file

@ -1741,7 +1741,7 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
* (for IF). * (for IF).
*/ */
if (index > 0) { if (index > 0) {
ni = Java_java_net_NetworkInterface_getByIndex(env, ni_class, ni = Java_java_net_NetworkInterface_getByIndex0(env, ni_class,
index); index);
if (ni == NULL) { if (ni == NULL) {
char errmsg[255]; char errmsg[255];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
#ifndef JDWP_UTIL_MD_H #ifndef JDWP_UTIL_MD_H
#define JDWP_UTIL_MD_H #define JDWP_UTIL_MD_H
#include <stddef.h> /* for uintptr_t */
#include <stdlib.h> /* for _MAx_PATH */ #include <stdlib.h> /* for _MAx_PATH */
typedef unsigned __int64 UNSIGNED_JLONG; typedef unsigned __int64 UNSIGNED_JLONG;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -29,7 +29,6 @@
#include "hpi_impl.h" #include "hpi_impl.h"
#include "mutex_md.h" #include "mutex_md.h"
#include "typedefs.h"
struct sockaddr; struct sockaddr;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,6 @@
#include "threads_md.h" #include "threads_md.h"
#include "monitor_md.h" #include "monitor_md.h"
#include "typedefs.h"
/* /*

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#include <stddef.h> /* For uintprt_t */
#include <stdlib.h> #include <stdlib.h>
#define MAXPATHLEN _MAX_PATH #define MAXPATHLEN _MAX_PATH

View file

@ -53,6 +53,7 @@ typedef struct {
WIN32_FIND_DATA find_data; WIN32_FIND_DATA find_data;
} DIR; } DIR;
#include <stddef.h> /* For uintptr_t */
#include <stdlib.h> #include <stdlib.h>
#define JVM_MAXPATHLEN _MAX_PATH #define JVM_MAXPATHLEN _MAX_PATH
@ -65,6 +66,19 @@ typedef struct {
JNIEXPORT void * JNICALL JNIEXPORT void * JNICALL
JVM_GetThreadInterruptEvent(); JVM_GetThreadInterruptEvent();
/*
* These routines are only reentrant on Windows
*/
JNIEXPORT struct protoent * JNICALL
JVM_GetProtoByName(char* name);
JNIEXPORT struct hostent* JNICALL
JVM_GetHostByAddr(const char* name, int len, int type);
JNIEXPORT struct hostent* JNICALL
JVM_GetHostByName(char* name);
/* /*
* File I/O * File I/O
*/ */

View file

@ -1,125 +0,0 @@
/*
* Copyright 1994-2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* Win32 dependent type definitions
*/
#ifndef _JAVASOFT_WIN32_TYPEDEF_MD_H_
#define _JAVASOFT_WIN32_TYPEDEF_MD_H_
#include <windows.h>
#define VARGS(x) (&x)
typedef char int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned char uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned int uint_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
/* Make sure that we have the intptr_t and uintptr_t definitions */
#ifndef _INTPTR_T_DEFINED
#ifdef _WIN64
typedef __int64 intptr_t;
#else
typedef int intptr_t;
#endif
#define _INTPTR_T_DEFINED
#endif
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
typedef intptr_t ssize_t;
/* use these macros when the compiler supports the long long type */
#define ll_high(a) ((long)((a)>>32))
#define ll_low(a) ((long)(a))
#define int2ll(a) ((int64_t)(a))
#define ll2int(a) ((int)(a))
#define ll_add(a, b) ((a) + (b))
#define ll_and(a, b) ((a) & (b))
#define ll_div(a, b) ((a) / (b))
#define ll_mul(a, b) ((a) * (b))
#define ll_neg(a) (-(a))
#define ll_not(a) (~(a))
#define ll_or(a, b) ((a) | (b))
/* THE FOLLOWING DEFINITION IS NOW A FUNCTION CALL IN ORDER TO WORKAROUND
OPTIMIZER BUG IN MSVC++ 2.1 (see system_md.c)
#define ll_shl(a, n) ((a) << (n)) */
#define ll_shr(a, n) ((a) >> (n))
#define ll_sub(a, b) ((a) - (b))
#define ll_ushr(a, n) ((uint64_t)(a) >> (n))
#define ll_xor(a, b) ((a) ^ (b))
#define uint2ll(a) ((uint64_t)(unsigned long)(a))
#define ll_rem(a,b) ((a) % (b))
int32_t float2l(float f);
int32_t double2l(double f);
int64_t float2ll(float f);
int64_t double2ll(double f);
#define ll2float(a) ((float) (a))
#define ll2double(a) ((double) (a))
/* Useful on machines where jlong and jdouble have different endianness. */
#define ll2double_bits(a) ((void) 0)
/* comparison operators */
#define ll_ltz(ll) ((ll) < 0)
#define ll_gez(ll) ((ll) >= 0)
#define ll_eqz(a) ((a) == 0)
#define ll_nez(a) ((a) != 0)
#define ll_eq(a, b) ((a) == (b))
#define ll_ne(a,b) ((a) != (b))
#define ll_ge(a,b) ((a) >= (b))
#define ll_le(a,b) ((a) <= (b))
#define ll_lt(a,b) ((a) < (b))
#define ll_gt(a,b) ((a) > (b))
#define ll_zero_const ((int64_t) 0)
#define ll_one_const ((int64_t) 1)
int64_t ll_shl(int64_t a, int bits);
#define ll2ptr(a) ((void*)(a))
#define ptr2ll(a) ((jlong)(a))
/* printf format modifier for printing pointers */
#define FORMAT64_MODIFIER "I64"
#endif /* !_JAVASOFT_WIN32_TYPEDEF_MD_H_ */

View file

@ -554,11 +554,11 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
ni_childsID = (*env)->GetFieldID(env, ni_class, "childs", "[Ljava/net/NetworkInterface;"); ni_childsID = (*env)->GetFieldID(env, ni_class, "childs", "[Ljava/net/NetworkInterface;");
ni_ctor = (*env)->GetMethodID(env, ni_class, "<init>", "()V"); ni_ctor = (*env)->GetMethodID(env, ni_class, "<init>", "()V");
ni_iacls = (*env)->FindClass(env, "Ljava/net/InetAddress;"); ni_iacls = (*env)->FindClass(env, "java/net/InetAddress");
ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); ni_iacls = (*env)->NewGlobalRef(env, ni_iacls);
ni_iaAddr = (*env)->GetFieldID(env, ni_iacls, "address", "I"); ni_iaAddr = (*env)->GetFieldID(env, ni_iacls, "address", "I");
ni_ia4cls = (*env)->FindClass(env, "Ljava/net/Inet4Address;"); ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address");
ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls);
ni_ia4Ctor = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V"); ni_ia4Ctor = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
@ -762,17 +762,17 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
/* /*
* Class: NetworkInterface * Class: NetworkInterface
* Method: getByIndex * Method: getByIndex0
* Signature: (I)LNetworkInterface; * Signature: (I)LNetworkInterface;
*/ */
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0
(JNIEnv *env, jclass cls, jint index) (JNIEnv *env, jclass cls, jint index)
{ {
netif *ifList, *curr; netif *ifList, *curr;
jobject netifObj = NULL; jobject netifObj = NULL;
if (os_supports_ipv6 && ipv6_available()) { if (os_supports_ipv6 && ipv6_available()) {
return Java_java_net_NetworkInterface_getByIndex_XP (env, cls, index); return Java_java_net_NetworkInterface_getByIndex0_XP (env, cls, index);
} }
/* get the list of interfaces */ /* get the list of interfaces */

View file

@ -576,10 +576,10 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0_XP
/* /*
* Class: NetworkInterface * Class: NetworkInterface
* Method: getByIndex * Method: getByIndex0_XP
* Signature: (I)LNetworkInterface; * Signature: (I)LNetworkInterface;
*/ */
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex_XP JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0_XP
(JNIEnv *env, jclass cls, jint index) (JNIEnv *env, jclass cls, jint index)
{ {
netif *ifList, *curr; netif *ifList, *curr;

View file

@ -2090,7 +2090,7 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1, jint o
* (for IF). * (for IF).
*/ */
if (index > 0) { if (index > 0) {
ni = Java_java_net_NetworkInterface_getByIndex(env, ni_class, ni = Java_java_net_NetworkInterface_getByIndex0(env, ni_class,
index); index);
if (ni == NULL) { if (ni == NULL) {
char errmsg[255]; char errmsg[255];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,6 @@
#include "net_util.h" #include "net_util.h"
#include "jni.h" #include "jni.h"
#include "typedefs.h"
#ifndef IPTOS_TOS_MASK #ifndef IPTOS_TOS_MASK
#define IPTOS_TOS_MASK 0x1e #define IPTOS_TOS_MASK 0x1e

View file

@ -329,7 +329,7 @@ extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0_XP JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0_XP
(JNIEnv *env, jclass cls, jstring name); (JNIEnv *env, jclass cls, jstring name);
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex_XP JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0_XP
(JNIEnv *env, jclass cls, jint index); (JNIEnv *env, jclass cls, jint index);
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0_XP JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0_XP

View file

@ -0,0 +1,58 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6717876
* @summary Make java.net.NetworkInterface.getIndex() public
*/
import java.net.*;
import java.util.Enumeration;
public class IndexTest {
public static void main(String[] args) throws Exception {
Enumeration<NetworkInterface> netifs = NetworkInterface.getNetworkInterfaces();
NetworkInterface nif = null;
while (netifs.hasMoreElements()) {
nif = netifs.nextElement();
int index = nif.getIndex();
if (index >= 0) {
NetworkInterface nif2 = NetworkInterface.getByIndex(index);
if (! nif.equals(nif2)) {
throw new RuntimeException("both interfaces should be equal");
}
}
}
try {
nif = NetworkInterface.getByIndex(-1);
throw new RuntimeException("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException e) {
// OK
}
// In all likelyhood, this interface should not exist.
nif = NetworkInterface.getByIndex(Integer.MAX_VALUE - 1);
if (nif != null) {
throw new RuntimeException("getByIndex() should have returned null");
}
}
}

View file

@ -0,0 +1,93 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6739302
* @summary Check that deserialization preserves EnumSet integrity
* @author Josh Bloch
*/
import java.util.*;
import java.io.*;
public class BogusEnumSet {
public static void main(String[] args) throws Throwable {
byte[] serializedForm = {
(byte)0xac, (byte)0xed, 0x0, 0x5, 0x73, 0x72, 0x0, 0x18,
0x6a, 0x61, 0x76, 0x61, 0x2e, 0x75, 0x74, 0x69,
0x6c, 0x2e, 0x52, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x45,
0x6e, 0x75, 0x6d, 0x53, 0x65, 0x74, 0x2f, 0x58, 0x6f, (byte)0xc7,
0x7e, (byte)0xb0, (byte)0xd0, 0x7e, 0x2, 0x0, 0x1, 0x4a, 0x0, 0x8,
0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x78, 0x72, 0x0,
0x11, 0x6a, 0x61, 0x76, 0x61, 0x2e, 0x75, 0x74, 0x69,
0x6c, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x65, 0x74, 0xe,
0x3, 0x21, 0x6a, (byte)0xcd, (byte)0x8c, 0x29, (byte)0xdd, 0x2,
0x0, 0x2, 0x4c, 0x0, 0xb, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74,
0x54, 0x79, 0x70, 0x65, 0x74, 0x0, 0x11, 0x4c, 0x6a, 0x61, 0x76,
0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x43, 0x6c, 0x61, 0x73,
0x73, 0x3b, 0x5b, 0x0, 0x8, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72,
0x73, 0x65, 0x74, 0x0, 0x11, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61,
0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x45, 0x6e, 0x75, 0x6d, 0x3b,
0x78, 0x70, 0x76, 0x72, 0x0, 0x16, 0x6a, 0x61, 0x76, 0x61, 0x2e,
0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x54, 0x68, 0x72, 0x65, 0x61,
0x64, 0x24, 0x53, 0x74, 0x61, 0x74, 0x65, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x12, 0x0, 0x0, 0x78, 0x72, 0x0, 0xe, 0x6a, 0x61,
0x76, 0x61, 0x2e, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x45, 0x6e, 0x75,
0x6d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x12, 0x0, 0x0, 0x78,
0x70, 0x75, 0x72, 0x0, 0x19, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61,
0x2e, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x54, 0x68, 0x72, 0x65, 0x61,
0x64, 0x24, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3b, 0x68, (byte)0xa3,
(byte)0xb5, (byte)0xd5, 0x11, 0x7d, 0x1b, (byte)0xb3, 0x2, 0x0,
0x0, 0x78, 0x70, 0x0, 0x0, 0x0, 0x6, 0x7e, 0x71, 0x0, 0x7e, 0x0,
0x5, 0x74, 0x0, 0x3, 0x4e, 0x45, 0x57, 0x7e, 0x71, 0x0, 0x7e, 0x0,
0x5, 0x74, 0x0, 0x8, 0x52, 0x55, 0x4e, 0x4e, 0x41, 0x42, 0x4c, 0x45,
0x7e, 0x71, 0x0, 0x7e, 0x0, 0x5, 0x74, 0x0, 0x7, 0x42, 0x4c, 0x4f,
0x43, 0x4b, 0x45, 0x44, 0x7e, 0x71, 0x0, 0x7e, 0x0, 0x5, 0x74, 0x0,
0x7, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, 0x7e, 0x71, 0x0,
0x7e, 0x0, 0x5, 0x74, 0x0, 0xd, 0x54, 0x49, 0x4d, 0x45, 0x44,
0x5f, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, 0x7e, 0x71, 0x0,
0x7e, 0x0, 0x5, 0x74, 0x0, 0xa, 0x54, 0x45, 0x52, 0x4d, 0x49,
0x4e, 0x41, 0x54, 0x45, 0x44, (byte)0xff, (byte)0xff, (byte)0xff,
(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff
};
try {
// Should fail, but instead creates corrupt EnumSet
@SuppressWarnings("unchecked")
EnumSet<Thread.State> es = (EnumSet<Thread.State>)
deserialize(serializedForm);
// Demonstrates corruption
System.out.println("Enum size: " + Thread.State.values().length); // 6
System.out.println("Set size: " + es.size()); // 64
System.out.println("Set: " + es); // Throws IndexOutOfBoundsException
throw new AssertionError("Expected exception InvalidObjectException not thrown");
} catch (java.io.InvalidObjectException _) { /* OK */ }
}
private static Object deserialize(byte[] sf) throws Throwable {
return new ObjectInputStream(
new ByteArrayInputStream(sf))
.readObject();
}
}

View file

@ -0,0 +1,393 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4486841
* @summary Test UTF-8 charset
*/
import java.nio.charset.*;
import java.nio.*;
import java.util.*;
public class TestUTF8 {
static char[] decode(byte[] bb, String csn, boolean testDirect)
throws Exception {
CharsetDecoder dec = Charset.forName(csn).newDecoder();
ByteBuffer bbf;
CharBuffer cbf;
if (testDirect) {
bbf = ByteBuffer.allocateDirect(bb.length);
cbf = ByteBuffer.allocateDirect(bb.length*2).asCharBuffer();
bbf.put(bb).flip();
} else {
bbf = ByteBuffer.wrap(bb);
cbf = CharBuffer.allocate(bb.length);
}
CoderResult cr = dec.decode(bbf, cbf, true);
if (cr != CoderResult.UNDERFLOW)
throw new RuntimeException("Decoding err: " + csn);
char[] cc = new char[cbf.position()];
cbf.flip(); cbf.get(cc);
return cc;
}
static CoderResult decodeCR(byte[] bb, String csn, boolean testDirect)
throws Exception {
CharsetDecoder dec = Charset.forName(csn).newDecoder();
ByteBuffer bbf;
CharBuffer cbf;
if (testDirect) {
bbf = ByteBuffer.allocateDirect(bb.length);
cbf = ByteBuffer.allocateDirect(bb.length*2).asCharBuffer();
bbf.put(bb).flip();
} else {
bbf = ByteBuffer.wrap(bb);
cbf = CharBuffer.allocate(bb.length);
}
return dec.decode(bbf, cbf, true);
}
static byte[] encode(char[] cc, String csn, boolean testDirect)
throws Exception {
ByteBuffer bbf;
CharBuffer cbf;
CharsetEncoder enc = Charset.forName(csn).newEncoder();
if (testDirect) {
bbf = ByteBuffer.allocateDirect(cc.length * 4);
cbf = ByteBuffer.allocateDirect(cc.length * 2).asCharBuffer();
cbf.put(cc).flip();
} else {
bbf = ByteBuffer.allocate(cc.length * 4);
cbf = CharBuffer.wrap(cc);
}
CoderResult cr = enc.encode(cbf, bbf, true);
if (cr != CoderResult.UNDERFLOW)
throw new RuntimeException("Encoding err: " + csn);
byte[] bb = new byte[bbf.position()];
bbf.flip(); bbf.get(bb);
return bb;
}
static CoderResult encodeCR(char[] cc, String csn, boolean testDirect)
throws Exception {
ByteBuffer bbf;
CharBuffer cbf;
CharsetEncoder enc = Charset.forName(csn).newEncoder();
if (testDirect) {
bbf = ByteBuffer.allocateDirect(cc.length * 4);
cbf = ByteBuffer.allocateDirect(cc.length * 2).asCharBuffer();
cbf.put(cc).flip();
} else {
bbf = ByteBuffer.allocate(cc.length * 4);
cbf = CharBuffer.wrap(cc);
}
return enc.encode(cbf, bbf, true);
}
static char[] getUTFChars() {
char[] cc = new char[0x10000 - 0xe000 + 0xd800 + //bmp
(0x110000 - 0x10000) * 2]; //supp
int pos = 0;
int i = 0;
for (i = 0; i < 0xd800; i++)
cc[pos++] = (char)i;
for (i = 0xe000; i < 0x10000; i++)
cc[pos++] = (char)i;
for (i = 0x10000; i < 0x110000; i++) {
pos += Character.toChars(i, cc, pos);
}
return cc;
}
static int to3ByteUTF8(char c, byte[] bb, int pos) {
bb[pos++] = (byte)(0xe0 | ((c >> 12)));
bb[pos++] = (byte)(0x80 | ((c >> 06) & 0x3f));
bb[pos++] = (byte)(0x80 | ((c >> 00) & 0x3f));
return 3;
}
static void checkRoundtrip(String csn) throws Exception {
System.out.printf(" Check roundtrip <%s>...", csn);
char[] cc = getUTFChars();
byte[] bb = encode(cc, csn, false);
char[] ccO = decode(bb, csn, false);
if (!Arrays.equals(cc, ccO)) {
System.out.printf(" non-direct failed");
}
bb = encode(cc, csn, true);
ccO = decode(bb, csn, true);
if (!Arrays.equals(cc, ccO)) {
System.out.printf(" (direct) failed");
}
System.out.println();
}
static void check6ByteSurrs(String csn) throws Exception {
System.out.printf(" Check 6-byte Surrogates <%s>...%n", csn);
byte[] bb = new byte[(0x110000 - 0x10000) * 6];
char[] cc = new char[(0x110000 - 0x10000) * 2];
int bpos = 0;
int cpos = 0;
for (int i = 0x10000; i < 0x110000; i++) {
Character.toChars(i, cc, cpos);
bpos += to3ByteUTF8(cc[cpos], bb, bpos);
bpos += to3ByteUTF8(cc[cpos + 1], bb, bpos);
cpos += 2;
}
char[] ccO = decode(bb, csn, false);
if (!Arrays.equals(cc, ccO)) {
System.out.printf(" decoding failed%n");
}
ccO = decode(bb, csn, true);
if (!Arrays.equals(cc, ccO)) {
System.out.printf(" decoding(direct) failed%n");
}
}
static void compare(String csn1, String csn2) throws Exception {
System.out.printf(" Diff <%s> <%s>...%n", csn1, csn2);
char[] cc = getUTFChars();
byte[] bb1 = encode(cc, csn1, false);
byte[] bb2 = encode(cc, csn2, false);
if (!Arrays.equals(bb1, bb2))
System.out.printf(" encoding failed%n");
char[] cc1 = decode(bb1, csn1, false);
char[] cc2 = decode(bb1, csn2, false);
if (!Arrays.equals(cc1, cc2)) {
System.out.printf(" decoding failed%n");
}
bb1 = encode(cc, csn1, true);
bb2 = encode(cc, csn2, true);
if (!Arrays.equals(bb1, bb2))
System.out.printf(" encoding (direct) failed%n");
cc1 = decode(bb1, csn1, true);
cc2 = decode(bb1, csn2, true);
if (!Arrays.equals(cc1, cc2)) {
System.out.printf(" decoding (direct) failed%n");
}
}
// The first byte is the length of malformed bytes
static byte[][] malformed = {
// One-byte sequences:
{1, (byte)0xFF },
{1, (byte)0xC0 },
{1, (byte)0x80 },
{1, (byte)0xFF, (byte)0xFF}, // all ones
{1, (byte)0xA0, (byte)0x80}, // 101x first byte first nibble
// Two-byte sequences:
{1, (byte)0xC0, (byte)0x80}, // invalid first byte
{1, (byte)0xC1, (byte)0xBF}, // invalid first byte
{1, (byte)0xC2, (byte)0x00}, // invalid second byte
{1, (byte)0xC2, (byte)0xC0}, // invalid second byte
{1, (byte)0xD0, (byte)0x00}, // invalid second byte
{1, (byte)0xD0, (byte)0xC0}, // invalid second byte
{1, (byte)0xDF, (byte)0x00}, // invalid second byte
{1, (byte)0xDF, (byte)0xC0}, // invalid second byte
// Three-byte sequences
{1, (byte)0xE0, (byte)0x80, (byte)0x80}, // 111x first byte first nibble
{1, (byte)0xE0, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{1, (byte)0xE0, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{1, (byte)0xE0, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
{1, (byte)0xE0, (byte)0xC0, (byte)0xBF }, // invalid second byte
{2, (byte)0xE0, (byte)0xA0, (byte)0x7F }, // invalid third byte
{2, (byte)0xE0, (byte)0xA0, (byte)0xC0 }, // invalid third byte
{1, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
{1, (byte)0xE0, (byte)0xC0, (byte)0x80 }, // invalid second byte
{1, (byte)0xE0, (byte)0x80, (byte)0xC0 }, // invalid first byte
// Four-byte sequences
{1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{1, (byte)0xF0, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{1, (byte)0xF0, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+007F zero-padded
{1, (byte)0xF0, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+07FF zero-padded
{1, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF }, // all ones
{1, (byte)0xF0, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid second byte
{1, (byte)0xF0, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
{2, (byte)0xF0, (byte)0x90, (byte)0xC0, (byte)0x80 }, // invalid third byte
{3, (byte)0xF0, (byte)0x90, (byte)0x80, (byte)0xC0 }, // invalid third byte
{1, (byte)0xF1, (byte)0xC0, (byte)0x80, (byte)0x80 }, // invalid second byte
{2, (byte)0xF1, (byte)0x80, (byte)0xC0, (byte)0x80 }, // invalid third byte
{3, (byte)0xF1, (byte)0x80, (byte)0x80, (byte)0xC0 }, // invalid forth byte
{1, (byte)0xF4, (byte)0x90, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
{1, (byte)0xF4, (byte)0xC0, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
{1, (byte)0xF5, (byte)0x80, (byte)0x80, (byte)0xC0 }, // out-range 4-byte
// Five-byte sequences
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80}, // invalid first byte
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
{5, (byte)0xF8, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
{1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80},
{2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80 },
{3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF },
{4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0 },
// Six-byte sequences
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 }, // U+0000 zero-padded
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x81, (byte)0xBF }, // U+007F zero-padded
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xBF }, // U+07FF zero-padded
{6, (byte)0xFC, (byte)0x80, (byte)0x80, (byte)0x8F, (byte)0xBF, (byte)0xBF }, // U+FFFF zero-padded
{1, (byte)0xF8, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80, (byte)0x80 },
{2, (byte)0xF8, (byte)0x80, (byte)0xC0, (byte)0x80, (byte)0x80, (byte)0x80 },
{3, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0xC1, (byte)0xBF, (byte)0x80 },
{4, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0xC0, (byte)0x80 },
{5, (byte)0xF8, (byte)0x80, (byte)0x80, (byte)0x9F, (byte)0x80, (byte)0xC0 },
};
static void checkMalformed(String csn) throws Exception {
boolean failed = false;
System.out.printf(" Check malformed <%s>...%n", csn);
for (boolean direct: new boolean[] {false, true}) {
for (byte[] bins : malformed) {
int mlen = bins[0];
byte[] bin = Arrays.copyOfRange(bins, 1, bins.length);
CoderResult cr = decodeCR(bin, csn, direct);
String ashex = "";
for (int i = 0; i < bin.length; i++) {
if (i > 0) ashex += " ";
ashex += Integer.toBinaryString((int)bin[i] & 0xff);
}
if (!cr.isMalformed()) {
System.out.printf(" FAIL(direct=%b): [%s] not malformed.\n", direct, ashex);
failed = true;
} else if (cr.length() != mlen) {
System.out.printf(" FAIL(direct=%b): [%s] malformed[len=%d].\n", direct, ashex, cr.length());
failed = true;
}
}
}
if (failed)
throw new RuntimeException("Check malformed failed " + csn);
}
static boolean check(CharsetDecoder dec, byte[] utf8s, boolean direct, int[] flow) {
int inPos = flow[0];
int inLen = flow[1];
int outPos = flow[2];
int outLen = flow[3];
int expedInPos = flow[4];
int expedOutPos = flow[5];
CoderResult expedCR = (flow[6]==0)?CoderResult.UNDERFLOW
:CoderResult.OVERFLOW;
ByteBuffer bbf;
CharBuffer cbf;
if (direct) {
bbf = ByteBuffer.allocateDirect(inPos + utf8s.length);
cbf = ByteBuffer.allocateDirect((outPos + outLen)*2).asCharBuffer();
} else {
bbf = ByteBuffer.allocate(inPos + utf8s.length);
cbf = CharBuffer.allocate(outPos + outLen);
}
bbf.position(inPos);
bbf.put(utf8s).flip().position(inPos).limit(inPos + inLen);
cbf.position(outPos);
dec.reset();
CoderResult cr = dec.decode(bbf, cbf, false);
if (cr != expedCR ||
bbf.position() != expedInPos ||
cbf.position() != expedOutPos) {
System.out.printf("Expected(direct=%5b): [", direct);
for (int i:flow) System.out.print(" " + i);
System.out.println("] CR=" + cr +
", inPos=" + bbf.position() +
", outPos=" + cbf.position());
return false;
}
return true;
}
static void checkUnderOverflow(String csn) throws Exception {
System.out.printf(" Check under/overflow <%s>...%n", csn);
CharsetDecoder dec = Charset.forName(csn).newDecoder();
boolean failed = false;
byte[] utf8s = new String("\u007f\u07ff\ue000\ud800\udc00").getBytes("UTF-8");
int inlen = utf8s.length;
for (int inoff = 0; inoff < 20; inoff++) {
for (int outoff = 0; outoff < 20; outoff++) {
int[][] Flows = {
//inpos, inLen, outPos, outLen, inPosEP, outposEP, under(0)/over(1)
{inoff, inlen, outoff, 1, inoff + 1, outoff + 1, 1},
{inoff, inlen, outoff, 2, inoff + 3, outoff + 2, 1},
{inoff, inlen, outoff, 3, inoff + 6, outoff + 3, 1},
{inoff, inlen, outoff, 4, inoff + 6, outoff + 3, 1},
{inoff, inlen, outoff, 5, inoff + 10,outoff + 5, 0},
// underflow
{inoff, 1, outoff, 5, inoff + 1, outoff + 1, 0},
{inoff, 2, outoff, 5, inoff + 1, outoff + 1, 0},
{inoff, 3, outoff, 5, inoff + 3, outoff + 2, 0},
{inoff, 4, outoff, 5, inoff + 3, outoff + 2, 0},
{inoff, 5, outoff, 5, inoff + 3, outoff + 2, 0},
{inoff, 6, outoff, 5, inoff + 6, outoff + 3, 0},
{inoff, 7, outoff, 5, inoff + 6, outoff + 3, 0},
{inoff, 8, outoff, 5, inoff + 6, outoff + 3, 0},
{inoff, 9, outoff, 5, inoff + 6, outoff + 3, 0},
{inoff, 10, outoff, 5, inoff + 10,outoff + 5, 0},
// 2-byte underflow/overflow
{inoff, 2, outoff, 1, inoff + 1, outoff + 1, 0},
{inoff, 3, outoff, 1, inoff + 1, outoff + 1, 1},
// 3-byte underflow/overflow
{inoff, 4, outoff, 2, inoff + 3, outoff + 2, 0},
{inoff, 5, outoff, 2, inoff + 3, outoff + 2, 0},
{inoff, 6, outoff, 2, inoff + 3, outoff + 2, 1},
// 4-byte underflow/overflow
{inoff, 7, outoff, 4, inoff + 6, outoff + 3, 0},
{inoff, 8, outoff, 4, inoff + 6, outoff + 3, 0},
{inoff, 9, outoff, 4, inoff + 6, outoff + 3, 0},
{inoff, 10, outoff, 4, inoff + 6, outoff + 3, 1},
};
for (boolean direct: new boolean[] {false, true}) {
for (int[] flow: Flows) {
if (!check(dec, utf8s, direct, flow))
failed = true;
}
}}}
if (failed)
throw new RuntimeException("Check under/overflow failed " + csn);
}
public static void main(String[] args) throws Exception {
checkRoundtrip("UTF-8");
check6ByteSurrs("UTF-8");
//compare("UTF-8", "UTF-8-OLD");
checkMalformed("UTF-8");
checkUnderOverflow("UTF-8");
}
}

View file

@ -0,0 +1,44 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6731685
* @summary CertificateFactory.generateCertificates throws IOException on PKCS7 cert chain
*/
import java.io.*;
import sun.security.util.*;
public class Indefinite {
public static void main(String[] args) throws Exception {
byte[] input = {
// An OCTET-STRING in 2 parts
4, (byte)0x80, 4, 2, 'a', 'b', 4, 2, 'c', 'd', 0, 0,
// Garbage follows, may be falsely recognized as EOC
0, 0, 0, 0
};
new DerValue(new ByteArrayInputStream(input));
}
}