mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +02:00
Merge
This commit is contained in:
commit
1619c53530
921 changed files with 60650 additions and 15232 deletions
2
.hgtags
2
.hgtags
|
@ -222,3 +222,5 @@ ea73f01b9053e7165e7ba80f242bafecbc6af712 jdk8-b96
|
||||||
711eb4aa87de68de78250e0549980936bab53d54 jdk8-b98
|
711eb4aa87de68de78250e0549980936bab53d54 jdk8-b98
|
||||||
2d3875b0d18b3ad1c2bebf385a697e309e4005a4 jdk8-b99
|
2d3875b0d18b3ad1c2bebf385a697e309e4005a4 jdk8-b99
|
||||||
3d34036aae4ea90b2ca59712d5a69db3221f0875 jdk8-b100
|
3d34036aae4ea90b2ca59712d5a69db3221f0875 jdk8-b100
|
||||||
|
edb01c460d4cab21ff0ff13512df7b746efaa0e7 jdk8-b101
|
||||||
|
bbe43d712fe08e650808d774861b256ccb34e500 jdk8-b102
|
||||||
|
|
|
@ -222,3 +222,5 @@ a1c1e8bf71f354f3aec0214cf13d6668811e021d jdk8-b97
|
||||||
0d0c983a817bbe8518a5ff201306334a8de267f2 jdk8-b98
|
0d0c983a817bbe8518a5ff201306334a8de267f2 jdk8-b98
|
||||||
59dc9da813794c924a0383c2a6241af94defdfed jdk8-b99
|
59dc9da813794c924a0383c2a6241af94defdfed jdk8-b99
|
||||||
d2dcb110e9dbaf9903c05b211df800e78e4b394e jdk8-b100
|
d2dcb110e9dbaf9903c05b211df800e78e4b394e jdk8-b100
|
||||||
|
9f74a220677dc265a724515d8e2617548cef62f1 jdk8-b101
|
||||||
|
5eb3c1dc348f72a7f84f7d9d07834e8bbe09a799 jdk8-b102
|
||||||
|
|
|
@ -222,3 +222,5 @@ c8286839d0df04aba819ec4bef12b86babccf30e jdk8-b90
|
||||||
3370fb6146e47a6cc05a213fc213e12fc0a38d07 jdk8-b98
|
3370fb6146e47a6cc05a213fc213e12fc0a38d07 jdk8-b98
|
||||||
3f67804ab61303782df57e54989ef5e0e4629beb jdk8-b99
|
3f67804ab61303782df57e54989ef5e0e4629beb jdk8-b99
|
||||||
8d492f1dfd1b131a4c7886ee6b59528609f7e4fe jdk8-b100
|
8d492f1dfd1b131a4c7886ee6b59528609f7e4fe jdk8-b100
|
||||||
|
a013024b07475782f1fa8e196e950b34b4077663 jdk8-b101
|
||||||
|
528c7e76eaeee022817ee085668459bc97cf5665 jdk8-b102
|
||||||
|
|
|
@ -1,528 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
package com.sun.corba.se.impl.encoding;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
import org.omg.CORBA.TypeCode;
|
|
||||||
import org.omg.CORBA.Principal;
|
|
||||||
import org.omg.CORBA.Any;
|
|
||||||
|
|
||||||
import com.sun.org.omg.SendingContext.CodeBase;
|
|
||||||
|
|
||||||
import com.sun.corba.se.pept.protocol.MessageMediator;
|
|
||||||
|
|
||||||
import com.sun.corba.se.spi.logging.CORBALogDomains;
|
|
||||||
import com.sun.corba.se.spi.orb.ORB;
|
|
||||||
import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
|
|
||||||
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
|
|
||||||
import com.sun.corba.se.impl.encoding.CodeSetConversion;
|
|
||||||
import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is delegates to the real implementation.
|
|
||||||
*
|
|
||||||
* NOTE:
|
|
||||||
*
|
|
||||||
* Before using the stream for valuetype unmarshaling, one must call
|
|
||||||
* performORBVersionSpecificInit().
|
|
||||||
*/
|
|
||||||
public abstract class CDRInputStream
|
|
||||||
extends org.omg.CORBA_2_3.portable.InputStream
|
|
||||||
implements com.sun.corba.se.impl.encoding.MarshalInputStream,
|
|
||||||
org.omg.CORBA.DataInputStream, org.omg.CORBA.portable.ValueInputStream
|
|
||||||
{
|
|
||||||
protected CorbaMessageMediator messageMediator;
|
|
||||||
private CDRInputStreamBase impl;
|
|
||||||
|
|
||||||
// We can move this out somewhere later. For now, it serves its purpose
|
|
||||||
// to create a concrete CDR delegate based on the GIOP version.
|
|
||||||
private static class InputStreamFactory {
|
|
||||||
|
|
||||||
public static CDRInputStreamBase newInputStream(ORB orb, GIOPVersion version)
|
|
||||||
{
|
|
||||||
switch(version.intValue()) {
|
|
||||||
case GIOPVersion.VERSION_1_0:
|
|
||||||
return new CDRInputStream_1_0();
|
|
||||||
case GIOPVersion.VERSION_1_1:
|
|
||||||
return new CDRInputStream_1_1();
|
|
||||||
case GIOPVersion.VERSION_1_2:
|
|
||||||
return new CDRInputStream_1_2();
|
|
||||||
default:
|
|
||||||
ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
|
|
||||||
CORBALogDomains.RPC_ENCODING ) ;
|
|
||||||
throw wrapper.unsupportedGiopVersion( version ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Required for the case when a ClientResponseImpl is
|
|
||||||
// created with a SystemException due to a dead server/closed
|
|
||||||
// connection with no warning. Note that the stream will
|
|
||||||
// not be initialized in this case.
|
|
||||||
//
|
|
||||||
// Probably also required by ServerRequestImpl.
|
|
||||||
//
|
|
||||||
// REVISIT.
|
|
||||||
public CDRInputStream() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public CDRInputStream(CDRInputStream is) {
|
|
||||||
impl = is.impl.dup();
|
|
||||||
impl.setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CDRInputStream(org.omg.CORBA.ORB orb,
|
|
||||||
ByteBuffer byteBuffer,
|
|
||||||
int size,
|
|
||||||
boolean littleEndian,
|
|
||||||
GIOPVersion version,
|
|
||||||
BufferManagerRead bufMgr)
|
|
||||||
{
|
|
||||||
impl = InputStreamFactory.newInputStream( (ORB)orb, version);
|
|
||||||
|
|
||||||
impl.init(orb, byteBuffer, size, littleEndian, bufMgr);
|
|
||||||
|
|
||||||
impl.setParent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// org.omg.CORBA.portable.InputStream
|
|
||||||
public final boolean read_boolean() {
|
|
||||||
return impl.read_boolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final char read_char() {
|
|
||||||
return impl.read_char();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final char read_wchar() {
|
|
||||||
return impl.read_wchar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final byte read_octet() {
|
|
||||||
return impl.read_octet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final short read_short() {
|
|
||||||
return impl.read_short();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final short read_ushort() {
|
|
||||||
return impl.read_ushort();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int read_long() {
|
|
||||||
return impl.read_long();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int read_ulong() {
|
|
||||||
return impl.read_ulong();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long read_longlong() {
|
|
||||||
return impl.read_longlong();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long read_ulonglong() {
|
|
||||||
return impl.read_ulonglong();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final float read_float() {
|
|
||||||
return impl.read_float();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final double read_double() {
|
|
||||||
return impl.read_double();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String read_string() {
|
|
||||||
return impl.read_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String read_wstring() {
|
|
||||||
return impl.read_wstring();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_boolean_array(boolean[] value, int offset, int length) {
|
|
||||||
impl.read_boolean_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_char_array(char[] value, int offset, int length) {
|
|
||||||
impl.read_char_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_wchar_array(char[] value, int offset, int length) {
|
|
||||||
impl.read_wchar_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_octet_array(byte[] value, int offset, int length) {
|
|
||||||
impl.read_octet_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_short_array(short[] value, int offset, int length) {
|
|
||||||
impl.read_short_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_ushort_array(short[] value, int offset, int length) {
|
|
||||||
impl.read_ushort_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_long_array(int[] value, int offset, int length) {
|
|
||||||
impl.read_long_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_ulong_array(int[] value, int offset, int length) {
|
|
||||||
impl.read_ulong_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_longlong_array(long[] value, int offset, int length) {
|
|
||||||
impl.read_longlong_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_ulonglong_array(long[] value, int offset, int length) {
|
|
||||||
impl.read_ulonglong_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_float_array(float[] value, int offset, int length) {
|
|
||||||
impl.read_float_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_double_array(double[] value, int offset, int length) {
|
|
||||||
impl.read_double_array(value, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final org.omg.CORBA.Object read_Object() {
|
|
||||||
return impl.read_Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final TypeCode read_TypeCode() {
|
|
||||||
return impl.read_TypeCode();
|
|
||||||
}
|
|
||||||
public final Any read_any() {
|
|
||||||
return impl.read_any();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Principal read_Principal() {
|
|
||||||
return impl.read_Principal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int read() throws java.io.IOException {
|
|
||||||
return impl.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.math.BigDecimal read_fixed() {
|
|
||||||
return impl.read_fixed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final org.omg.CORBA.Context read_Context() {
|
|
||||||
return impl.read_Context();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final org.omg.CORBA.Object read_Object(java.lang.Class clz) {
|
|
||||||
return impl.read_Object(clz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final org.omg.CORBA.ORB orb() {
|
|
||||||
return impl.orb();
|
|
||||||
}
|
|
||||||
|
|
||||||
// org.omg.CORBA_2_3.portable.InputStream
|
|
||||||
public final java.io.Serializable read_value() {
|
|
||||||
return impl.read_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.io.Serializable read_value(java.lang.Class clz) {
|
|
||||||
return impl.read_value(clz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.io.Serializable read_value(org.omg.CORBA.portable.BoxedValueHelper factory) {
|
|
||||||
return impl.read_value(factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.io.Serializable read_value(java.lang.String rep_id) {
|
|
||||||
return impl.read_value(rep_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.io.Serializable read_value(java.io.Serializable value) {
|
|
||||||
return impl.read_value(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.lang.Object read_abstract_interface() {
|
|
||||||
return impl.read_abstract_interface();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.lang.Object read_abstract_interface(java.lang.Class clz) {
|
|
||||||
return impl.read_abstract_interface(clz);
|
|
||||||
}
|
|
||||||
// com.sun.corba.se.impl.encoding.MarshalInputStream
|
|
||||||
|
|
||||||
public final void consumeEndian() {
|
|
||||||
impl.consumeEndian();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getPosition() {
|
|
||||||
return impl.getPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
// org.omg.CORBA.DataInputStream
|
|
||||||
|
|
||||||
public final java.lang.Object read_Abstract () {
|
|
||||||
return impl.read_Abstract();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final java.io.Serializable read_Value () {
|
|
||||||
return impl.read_Value();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_any_array (org.omg.CORBA.AnySeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_any_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_boolean_array (org.omg.CORBA.BooleanSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_boolean_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_char_array (org.omg.CORBA.CharSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_char_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_wchar_array (org.omg.CORBA.WCharSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_wchar_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_octet_array (org.omg.CORBA.OctetSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_octet_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_short_array (org.omg.CORBA.ShortSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_short_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_ushort_array (org.omg.CORBA.UShortSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_ushort_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_long_array (org.omg.CORBA.LongSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_long_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_ulong_array (org.omg.CORBA.ULongSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_ulong_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_ulonglong_array (org.omg.CORBA.ULongLongSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_ulonglong_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_longlong_array (org.omg.CORBA.LongLongSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_longlong_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_float_array (org.omg.CORBA.FloatSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_float_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void read_double_array (org.omg.CORBA.DoubleSeqHolder seq, int offset, int length) {
|
|
||||||
impl.read_double_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
// org.omg.CORBA.portable.ValueBase
|
|
||||||
public final String[] _truncatable_ids() {
|
|
||||||
return impl._truncatable_ids();
|
|
||||||
}
|
|
||||||
|
|
||||||
// java.io.InputStream
|
|
||||||
public final int read(byte b[]) throws IOException {
|
|
||||||
return impl.read(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int read(byte b[], int off, int len) throws IOException {
|
|
||||||
return impl.read(b, off, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long skip(long n) throws IOException {
|
|
||||||
return impl.skip(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int available() throws IOException {
|
|
||||||
return impl.available();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void close() throws IOException {
|
|
||||||
impl.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void mark(int readlimit) {
|
|
||||||
impl.mark(readlimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void reset() {
|
|
||||||
impl.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean markSupported() {
|
|
||||||
return impl.markSupported();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract CDRInputStream dup();
|
|
||||||
|
|
||||||
// Needed by TCUtility
|
|
||||||
public final java.math.BigDecimal read_fixed(short digits, short scale) {
|
|
||||||
return impl.read_fixed(digits, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean isLittleEndian() {
|
|
||||||
return impl.isLittleEndian();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final ByteBuffer getByteBuffer() {
|
|
||||||
return impl.getByteBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final void setByteBuffer(ByteBuffer byteBuffer) {
|
|
||||||
impl.setByteBuffer(byteBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final void setByteBufferWithInfo(ByteBufferWithInfo bbwi) {
|
|
||||||
impl.setByteBufferWithInfo(bbwi);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getBufferLength() {
|
|
||||||
return impl.getBufferLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final void setBufferLength(int value) {
|
|
||||||
impl.setBufferLength(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final int getIndex() {
|
|
||||||
return impl.getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final void setIndex(int value) {
|
|
||||||
impl.setIndex(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void orb(org.omg.CORBA.ORB orb) {
|
|
||||||
impl.orb(orb);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final GIOPVersion getGIOPVersion() {
|
|
||||||
return impl.getGIOPVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final BufferManagerRead getBufferManager() {
|
|
||||||
return impl.getBufferManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This should be overridden by any stream (ex: IIOPInputStream)
|
|
||||||
// which wants to read values. Thus, TypeCodeInputStream doesn't
|
|
||||||
// have to do this.
|
|
||||||
public CodeBase getCodeBase() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use Latin-1 for GIOP 1.0 or when code set negotiation was not
|
|
||||||
// performed.
|
|
||||||
protected CodeSetConversion.BTCConverter createCharBTCConverter() {
|
|
||||||
return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.ISO_8859_1,
|
|
||||||
impl.isLittleEndian());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subclasses must decide what to do here. It's inconvenient to
|
|
||||||
// make the class and this method abstract because of dup().
|
|
||||||
protected abstract CodeSetConversion.BTCConverter createWCharBTCConverter();
|
|
||||||
|
|
||||||
// Prints the current buffer in a human readable form
|
|
||||||
void printBuffer() {
|
|
||||||
impl.printBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Aligns the current position on the given octet boundary
|
|
||||||
* if there are enough bytes available to do so. Otherwise,
|
|
||||||
* it just returns. This is used for some (but not all)
|
|
||||||
* GIOP 1.2 message headers.
|
|
||||||
*/
|
|
||||||
public void alignOnBoundary(int octetBoundary) {
|
|
||||||
impl.alignOnBoundary(octetBoundary);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Needed by request and reply messages for GIOP versions >= 1.2 only.
|
|
||||||
public void setHeaderPadding(boolean headerPadding) {
|
|
||||||
impl.setHeaderPadding(headerPadding);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This must be called after determining the proper ORB version,
|
|
||||||
* and setting it on the stream's ORB instance. It can be called
|
|
||||||
* after reading the service contexts, since that is the only place
|
|
||||||
* we can get the ORB version info.
|
|
||||||
*
|
|
||||||
* Trying to unmarshal things requiring repository IDs before calling
|
|
||||||
* this will result in NullPtrExceptions.
|
|
||||||
*/
|
|
||||||
public void performORBVersionSpecificInit() {
|
|
||||||
// In the case of SystemExceptions, a stream is created
|
|
||||||
// with its default constructor (and thus no impl is set).
|
|
||||||
if (impl != null)
|
|
||||||
impl.performORBVersionSpecificInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets any internal references to code set converters.
|
|
||||||
* This is useful for forcing the CDR stream to reacquire
|
|
||||||
* converters (probably from its subclasses) when state
|
|
||||||
* has changed.
|
|
||||||
*/
|
|
||||||
public void resetCodeSetConverters() {
|
|
||||||
impl.resetCodeSetConverters();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageMediator(MessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
this.messageMediator = (CorbaMessageMediator) messageMediator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageMediator getMessageMediator()
|
|
||||||
{
|
|
||||||
return messageMediator;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValueInputStream -----------------------------
|
|
||||||
|
|
||||||
public void start_value() {
|
|
||||||
impl.start_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void end_value() {
|
|
||||||
impl.end_value();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,435 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
package com.sun.corba.se.impl.encoding;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
import org.omg.CORBA.TypeCode;
|
|
||||||
import org.omg.CORBA.Principal;
|
|
||||||
import org.omg.CORBA.Any;
|
|
||||||
|
|
||||||
import com.sun.corba.se.pept.protocol.MessageMediator;
|
|
||||||
|
|
||||||
import com.sun.corba.se.spi.orb.ORB;
|
|
||||||
import com.sun.corba.se.spi.logging.CORBALogDomains;
|
|
||||||
import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
|
|
||||||
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.encoding.CodeSetConversion;
|
|
||||||
import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry;
|
|
||||||
import com.sun.corba.se.impl.orbutil.ORBConstants;
|
|
||||||
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is delegates to the real implementation.
|
|
||||||
*/
|
|
||||||
public abstract class CDROutputStream
|
|
||||||
extends org.omg.CORBA_2_3.portable.OutputStream
|
|
||||||
implements com.sun.corba.se.impl.encoding.MarshalOutputStream,
|
|
||||||
org.omg.CORBA.DataOutputStream, org.omg.CORBA.portable.ValueOutputStream
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
private CDROutputStreamBase impl;
|
|
||||||
protected ORB orb ;
|
|
||||||
protected ORBUtilSystemException wrapper ;
|
|
||||||
protected CorbaMessageMediator corbaMessageMediator;
|
|
||||||
|
|
||||||
|
|
||||||
// We can move this out somewhere later. For now, it serves its purpose
|
|
||||||
// to create a concrete CDR delegate based on the GIOP version.
|
|
||||||
private static class OutputStreamFactory {
|
|
||||||
|
|
||||||
public static CDROutputStreamBase newOutputStream(ORB orb, GIOPVersion version)
|
|
||||||
{
|
|
||||||
switch(version.intValue()) {
|
|
||||||
case GIOPVersion.VERSION_1_0:
|
|
||||||
return new CDROutputStream_1_0();
|
|
||||||
case GIOPVersion.VERSION_1_1:
|
|
||||||
return new CDROutputStream_1_1();
|
|
||||||
case GIOPVersion.VERSION_1_2:
|
|
||||||
return new CDROutputStream_1_2();
|
|
||||||
default:
|
|
||||||
ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
|
|
||||||
CORBALogDomains.RPC_ENCODING ) ;
|
|
||||||
// REVISIT - what is appropriate? INTERNAL exceptions
|
|
||||||
// are really hard to track later.
|
|
||||||
throw wrapper.unsupportedGiopVersion( version ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// REVISIT - These two constructors should be re-factored to better hide
|
|
||||||
// the fact that someone extending this class 'can' construct a CDROutputStream
|
|
||||||
// that does not use pooled ByteBuffers. Right now, only EncapsOutputStream
|
|
||||||
// does _not_ use pooled ByteBuffers, see EncapsOutputStream.
|
|
||||||
|
|
||||||
// NOTE: When a stream is constructed for non-channel-backed sockets
|
|
||||||
// it notifies the constructor not to use pooled (i.e, direct)
|
|
||||||
// ByteBuffers.
|
|
||||||
|
|
||||||
public CDROutputStream(ORB orb,
|
|
||||||
GIOPVersion version,
|
|
||||||
boolean littleEndian,
|
|
||||||
BufferManagerWrite bufferManager,
|
|
||||||
byte streamFormatVersion,
|
|
||||||
boolean usePooledByteBuffers)
|
|
||||||
{
|
|
||||||
impl = OutputStreamFactory.newOutputStream(orb, version);
|
|
||||||
impl.init(orb, littleEndian, bufferManager, streamFormatVersion, usePooledByteBuffers);
|
|
||||||
|
|
||||||
impl.setParent(this);
|
|
||||||
this.orb = orb ;
|
|
||||||
this.wrapper = ORBUtilSystemException.get( orb,
|
|
||||||
CORBALogDomains.RPC_ENCODING ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CDROutputStream(ORB orb,
|
|
||||||
GIOPVersion version,
|
|
||||||
boolean littleEndian,
|
|
||||||
BufferManagerWrite bufferManager,
|
|
||||||
byte streamFormatVersion)
|
|
||||||
{
|
|
||||||
this(orb, version, littleEndian, bufferManager, streamFormatVersion, true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private ByteArrayOutputStream bos ;
|
|
||||||
private ObjectOutputStream oos ;
|
|
||||||
|
|
||||||
public JavaOutputStream()
|
|
||||||
{
|
|
||||||
bos = new ByteArrayOutputStream() ;
|
|
||||||
oos = new ObjectOutputStream( bos ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provided by IIOPOutputStream and EncapsOutputStream
|
|
||||||
public org.omg.CORBA.portable.InputStream create_input_stream()
|
|
||||||
{
|
|
||||||
ObjectInputStream ois = new ByteArrayInputStream( bos.toByteArray() ) ;
|
|
||||||
|
|
||||||
return new JavaInputStream( ois ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_boolean(boolean value) {
|
|
||||||
impl.write_boolean(value);
|
|
||||||
}
|
|
||||||
public final void write_char(char value) {
|
|
||||||
impl.write_char(value);
|
|
||||||
}
|
|
||||||
public final void write_wchar(char value) {
|
|
||||||
impl.write_wchar(value);
|
|
||||||
}
|
|
||||||
public final void write_octet(byte value) {
|
|
||||||
impl.write_octet(value);
|
|
||||||
}
|
|
||||||
public final void write_short(short value) {
|
|
||||||
impl.write_short(value);
|
|
||||||
}
|
|
||||||
public final void write_ushort(short value) {
|
|
||||||
impl.write_ushort(value);
|
|
||||||
}
|
|
||||||
public final void write_long(int value) {
|
|
||||||
impl.write_long(value);
|
|
||||||
}
|
|
||||||
public final void write_ulong(int value) {
|
|
||||||
impl.write_ulong(value);
|
|
||||||
}
|
|
||||||
public final void write_longlong(long value) {
|
|
||||||
impl.write_longlong(value);
|
|
||||||
}
|
|
||||||
public final void write_ulonglong(long value) {
|
|
||||||
impl.write_ulonglong(value);
|
|
||||||
}
|
|
||||||
public final void write_float(float value) {
|
|
||||||
impl.write_float(value);
|
|
||||||
}
|
|
||||||
public final void write_double(double value) {
|
|
||||||
impl.write_double(value);
|
|
||||||
}
|
|
||||||
public final void write_string(String value) {
|
|
||||||
impl.write_string(value);
|
|
||||||
}
|
|
||||||
public final void write_wstring(String value) {
|
|
||||||
impl.write_wstring(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_boolean_array(boolean[] value, int offset, int length) {
|
|
||||||
impl.write_boolean_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_char_array(char[] value, int offset, int length) {
|
|
||||||
impl.write_char_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_wchar_array(char[] value, int offset, int length) {
|
|
||||||
impl.write_wchar_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_octet_array(byte[] value, int offset, int length) {
|
|
||||||
impl.write_octet_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_short_array(short[] value, int offset, int length) {
|
|
||||||
impl.write_short_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_ushort_array(short[] value, int offset, int length){
|
|
||||||
impl.write_ushort_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_long_array(int[] value, int offset, int length) {
|
|
||||||
impl.write_long_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_ulong_array(int[] value, int offset, int length) {
|
|
||||||
impl.write_ulong_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_longlong_array(long[] value, int offset, int length) {
|
|
||||||
impl.write_longlong_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_ulonglong_array(long[] value, int offset,int length) {
|
|
||||||
impl.write_ulonglong_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_float_array(float[] value, int offset, int length) {
|
|
||||||
impl.write_float_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_double_array(double[] value, int offset, int length) {
|
|
||||||
impl.write_double_array(value, offset, length);
|
|
||||||
}
|
|
||||||
public final void write_Object(org.omg.CORBA.Object value) {
|
|
||||||
impl.write_Object(value);
|
|
||||||
}
|
|
||||||
public final void write_TypeCode(TypeCode value) {
|
|
||||||
impl.write_TypeCode(value);
|
|
||||||
}
|
|
||||||
public final void write_any(Any value) {
|
|
||||||
impl.write_any(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_Principal(Principal value) {
|
|
||||||
impl.write_Principal(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write(int b) throws java.io.IOException {
|
|
||||||
impl.write(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_fixed(java.math.BigDecimal value) {
|
|
||||||
impl.write_fixed(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_Context(org.omg.CORBA.Context ctx,
|
|
||||||
org.omg.CORBA.ContextList contexts) {
|
|
||||||
impl.write_Context(ctx, contexts);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final org.omg.CORBA.ORB orb() {
|
|
||||||
return impl.orb();
|
|
||||||
}
|
|
||||||
|
|
||||||
// org.omg.CORBA_2_3.portable.OutputStream
|
|
||||||
public final void write_value(java.io.Serializable value) {
|
|
||||||
impl.write_value(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_value(java.io.Serializable value, java.lang.Class clz) {
|
|
||||||
impl.write_value(value, clz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_value(java.io.Serializable value, String repository_id) {
|
|
||||||
impl.write_value(value, repository_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_value(java.io.Serializable value,
|
|
||||||
org.omg.CORBA.portable.BoxedValueHelper factory) {
|
|
||||||
impl.write_value(value, factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_abstract_interface(java.lang.Object obj) {
|
|
||||||
impl.write_abstract_interface(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
// java.io.OutputStream
|
|
||||||
public final void write(byte b[]) throws IOException {
|
|
||||||
impl.write(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write(byte b[], int off, int len) throws IOException {
|
|
||||||
impl.write(b, off, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void flush() throws IOException {
|
|
||||||
impl.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void close() throws IOException {
|
|
||||||
impl.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// com.sun.corba.se.impl.encoding.MarshalOutputStream
|
|
||||||
public final void start_block() {
|
|
||||||
impl.start_block();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void end_block() {
|
|
||||||
impl.end_block();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void putEndian() {
|
|
||||||
impl.putEndian();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeTo(java.io.OutputStream s)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
impl.writeTo(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final byte[] toByteArray() {
|
|
||||||
return impl.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
// org.omg.CORBA.DataOutputStream
|
|
||||||
public final void write_Abstract (java.lang.Object value) {
|
|
||||||
impl.write_Abstract(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_Value (java.io.Serializable value) {
|
|
||||||
impl.write_Value(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_any_array(org.omg.CORBA.Any[] seq, int offset, int length) {
|
|
||||||
impl.write_any_array(seq, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageMediator(MessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
this.corbaMessageMediator = (CorbaMessageMediator) messageMediator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageMediator getMessageMediator()
|
|
||||||
{
|
|
||||||
return corbaMessageMediator;
|
|
||||||
}
|
|
||||||
|
|
||||||
// org.omg.CORBA.portable.ValueBase
|
|
||||||
public final String[] _truncatable_ids() {
|
|
||||||
return impl._truncatable_ids();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Other
|
|
||||||
protected final int getSize() {
|
|
||||||
return impl.getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final int getIndex() {
|
|
||||||
return impl.getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getRealIndex(int index) {
|
|
||||||
// Used in indirections. Overridden by TypeCodeOutputStream.
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final void setIndex(int value) {
|
|
||||||
impl.setIndex(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final ByteBuffer getByteBuffer() {
|
|
||||||
return impl.getByteBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final void setByteBuffer(ByteBuffer byteBuffer) {
|
|
||||||
impl.setByteBuffer(byteBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean isLittleEndian() {
|
|
||||||
return impl.isLittleEndian();
|
|
||||||
}
|
|
||||||
|
|
||||||
// XREVISIT - return to final if possible
|
|
||||||
// REVISIT - was protected - need access from msgtypes test.
|
|
||||||
public ByteBufferWithInfo getByteBufferWithInfo() {
|
|
||||||
return impl.getByteBufferWithInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setByteBufferWithInfo(ByteBufferWithInfo bbwi) {
|
|
||||||
impl.setByteBufferWithInfo(bbwi);
|
|
||||||
}
|
|
||||||
|
|
||||||
// REVISIT: was protected - but need to access from xgiop.
|
|
||||||
public final BufferManagerWrite getBufferManager() {
|
|
||||||
return impl.getBufferManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void write_fixed(java.math.BigDecimal bigDecimal, short digits, short scale) {
|
|
||||||
impl.write_fixed(bigDecimal, digits, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void writeOctetSequenceTo(org.omg.CORBA.portable.OutputStream s) {
|
|
||||||
impl.writeOctetSequenceTo(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final GIOPVersion getGIOPVersion() {
|
|
||||||
return impl.getGIOPVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void writeIndirection(int tag, int posIndirectedTo) {
|
|
||||||
impl.writeIndirection(tag, posIndirectedTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use Latin-1 for GIOP 1.0 or when code set negotiation was not
|
|
||||||
// performed.
|
|
||||||
protected CodeSetConversion.CTBConverter createCharCTBConverter() {
|
|
||||||
return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.ISO_8859_1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subclasses must decide what to do here. It's inconvenient to
|
|
||||||
// make the class and this method abstract because of dup().
|
|
||||||
protected abstract CodeSetConversion.CTBConverter createWCharCTBConverter();
|
|
||||||
|
|
||||||
protected final void freeInternalCaches() {
|
|
||||||
impl.freeInternalCaches();
|
|
||||||
}
|
|
||||||
|
|
||||||
void printBuffer() {
|
|
||||||
impl.printBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void alignOnBoundary(int octetBoundary) {
|
|
||||||
impl.alignOnBoundary(octetBoundary);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Needed by request and reply messages for GIOP versions >= 1.2 only.
|
|
||||||
public void setHeaderPadding(boolean headerPadding) {
|
|
||||||
impl.setHeaderPadding(headerPadding);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValueOutputStream -----------------------------
|
|
||||||
|
|
||||||
public void start_value(String rep_id) {
|
|
||||||
impl.start_value(rep_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void end_value() {
|
|
||||||
impl.end_value();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,164 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2000, 2002, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.interceptors;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.corba.AnyImpl;
|
|
||||||
import org.omg.PortableInterceptor.Current;
|
|
||||||
import org.omg.PortableInterceptor.InvalidSlot;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.util.MinorCodes;
|
|
||||||
import com.sun.corba.se.impl.core.ORB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ThreadCurrentStack is the container of PICurrent instances for each thread
|
|
||||||
*/
|
|
||||||
public class ThreadCurrentStack
|
|
||||||
{
|
|
||||||
// PICurrentPool is the container for reusable PICurrents
|
|
||||||
private class PICurrentPool {
|
|
||||||
|
|
||||||
// Contains a list of reusable PICurrents
|
|
||||||
private java.util.ArrayList pool;
|
|
||||||
|
|
||||||
// High water mark for the pool
|
|
||||||
// If the pool size reaches this limit then putPICurrent will
|
|
||||||
// not put PICurrent to the pool.
|
|
||||||
private static final int HIGH_WATER_MARK = 5;
|
|
||||||
|
|
||||||
// currentIndex points to the last PICurrent in the list
|
|
||||||
private int currentIndex;
|
|
||||||
|
|
||||||
PICurrentPool( ) {
|
|
||||||
pool = new java.util.ArrayList( HIGH_WATER_MARK );
|
|
||||||
currentIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Puts PICurrent to the re-usable pool.
|
|
||||||
*/
|
|
||||||
void putPICurrent( PICurrent current ) {
|
|
||||||
// If there are enough PICurrents in the pool, then don't add
|
|
||||||
// this current to the pool.
|
|
||||||
if( currentIndex >= HIGH_WATER_MARK ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pool.add(currentIndex , current);
|
|
||||||
currentIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets PICurrent from the re-usable pool.
|
|
||||||
*/
|
|
||||||
PICurrent getPICurrent( ) {
|
|
||||||
// If there are no entries in the pool then return null
|
|
||||||
if( currentIndex == 0 ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Works like a stack, Gets the last one added first
|
|
||||||
currentIndex--;
|
|
||||||
return (PICurrent) pool.get(currentIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Contains all the active PICurrents for each thread.
|
|
||||||
// The ArrayList is made to behave like a stack.
|
|
||||||
private java.util.ArrayList currentContainer;
|
|
||||||
|
|
||||||
// Keeps track of number of PICurrents in the stack.
|
|
||||||
private int currentIndex;
|
|
||||||
|
|
||||||
// For Every Thread there will be a pool of re-usable ThreadCurrent's
|
|
||||||
// stored in PICurrentPool
|
|
||||||
private PICurrentPool currentPool;
|
|
||||||
|
|
||||||
// The orb associated with this ThreadCurrentStack
|
|
||||||
private ORB piOrb;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs the stack and and PICurrentPool
|
|
||||||
*/
|
|
||||||
ThreadCurrentStack( ORB piOrb, PICurrent current ) {
|
|
||||||
this.piOrb = piOrb;
|
|
||||||
currentIndex = 0;
|
|
||||||
currentContainer = new java.util.ArrayList( );
|
|
||||||
currentPool = new PICurrentPool( );
|
|
||||||
currentContainer.add( currentIndex, current );
|
|
||||||
currentIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* pushPICurrent goes through the following steps
|
|
||||||
* 1: Checks to see if there is any PICurrent in PICurrentPool
|
|
||||||
* If present then use that instance to push into the ThreadCurrentStack
|
|
||||||
*
|
|
||||||
* 2:If there is no PICurrent in the pool, then creates a new one and pushes
|
|
||||||
* that into the ThreadCurrentStack
|
|
||||||
*/
|
|
||||||
void pushPICurrent( ) {
|
|
||||||
PICurrent current = currentPool.getPICurrent( );
|
|
||||||
if( current == null ) {
|
|
||||||
// get an existing PICurrent to get the slotSize
|
|
||||||
PICurrent currentTemp = peekPICurrent();
|
|
||||||
current = new PICurrent( piOrb, currentTemp.getSlotSize( ));
|
|
||||||
}
|
|
||||||
currentContainer.add( currentIndex, current );
|
|
||||||
currentIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* popPICurrent does the following
|
|
||||||
* 1: pops the top PICurrent in the ThreadCurrentStack
|
|
||||||
*
|
|
||||||
* 2: resets the slots in the PICurrent which resets the slotvalues to
|
|
||||||
* null if there are any previous sets.
|
|
||||||
*
|
|
||||||
* 3: pushes the reset PICurrent into the PICurrentPool to reuse
|
|
||||||
*/
|
|
||||||
void popPICurrent( ) {
|
|
||||||
// Do not pop the PICurrent, If there is only one.
|
|
||||||
// This should not happen, But an extra check for safety.
|
|
||||||
if( currentIndex <= 1 ) {
|
|
||||||
throw new org.omg.CORBA.INTERNAL(
|
|
||||||
"Cannot pop the only PICurrent in the stack",
|
|
||||||
MinorCodes.CANT_POP_ONLY_CURRENT_2,
|
|
||||||
CompletionStatus.COMPLETED_NO );
|
|
||||||
}
|
|
||||||
currentIndex--;
|
|
||||||
PICurrent current = (PICurrent)currentContainer.get( currentIndex );
|
|
||||||
current.resetSlots( );
|
|
||||||
currentPool.putPICurrent( current );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* peekPICurrent gets the top PICurrent in the ThreadCurrentStack without
|
|
||||||
* popping.
|
|
||||||
*/
|
|
||||||
PICurrent peekPICurrent( ) {
|
|
||||||
return (PICurrent) currentContainer.get( currentIndex - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.orbutil ;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
|
|
||||||
/** This class provides just a main method. Its purpose is to allow -D arguments to
|
|
||||||
* set up the system properties when starting programs with tools like OptimizeIt that
|
|
||||||
* make this difficult or impossible.
|
|
||||||
*
|
|
||||||
* Invocation: {java launcher of some kind} DefineClass -Dxxx=yyy -Dxxx=yyy ... {class name} arg0, arg1, ...
|
|
||||||
* Result: updates system properties with -D args, then uses reflection to invoke {class name}.main with the args
|
|
||||||
*/
|
|
||||||
|
|
||||||
class DefineWrapper {
|
|
||||||
public static void main( String[] args )
|
|
||||||
{
|
|
||||||
int numberDefines = args.length ;
|
|
||||||
String className = null ;
|
|
||||||
|
|
||||||
for (int ctr=0; ctr<args.length; ctr++ ) {
|
|
||||||
String arg = args[ctr] ;
|
|
||||||
|
|
||||||
if ((arg.charAt(0) == '-') && (arg.charAt(1) == 'D')) {
|
|
||||||
int eqIndex = arg.indexOf( '=' ) ;
|
|
||||||
if (eqIndex < 0)
|
|
||||||
throw new Exception( arg + " is not a valid property assignment" ) ;
|
|
||||||
|
|
||||||
final String key = arg.subString( 2, eqIndex ) ;
|
|
||||||
final String value = arg.subStrung( eqIndex + 1 ) ;
|
|
||||||
|
|
||||||
AccessController.doPrivileged( new PrivilegedAction() {
|
|
||||||
public Object run() {
|
|
||||||
System.setProperty( key, value ) ;
|
|
||||||
return null ;
|
|
||||||
}
|
|
||||||
} ) ;
|
|
||||||
} else {
|
|
||||||
numberDefines = ctr ;
|
|
||||||
className = arg ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numberDefines < args.length) {
|
|
||||||
Class cls = getMainClass( className ) ;
|
|
||||||
Method mainMethod = getMainMethod( cls ) ;
|
|
||||||
|
|
||||||
String[] newArgs = new String[ args.length - numberDefines ] ;
|
|
||||||
for (int ctr = numberDefines+1; ctr<args.length; ctr++ ) {
|
|
||||||
newArgs[ ctr-numberDefines-1 ] = args[ ctr ] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// build args to the main and call it
|
|
||||||
Object params [] = new Object [1];
|
|
||||||
params[0] = newArgs;
|
|
||||||
mainMethod.invoke(null, params);
|
|
||||||
} else {
|
|
||||||
throw new Exception( "No class name given" ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Class getMainClass( String name )
|
|
||||||
{
|
|
||||||
// determine the class loader to be used for loading the class
|
|
||||||
// since ServerMain is going to be in JDK and we need to have this
|
|
||||||
// class to load application classes, this is required here.
|
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
|
||||||
|
|
||||||
if (cl == null)
|
|
||||||
cl = ClassLoader.getSystemClassLoader();
|
|
||||||
|
|
||||||
try {
|
|
||||||
// determine the main class, try loading with current class loader
|
|
||||||
cls = Class.forName( className ) ;
|
|
||||||
} catch (ClassNotFoundException ex) {
|
|
||||||
// eat the exception and try to load using SystemClassLoader
|
|
||||||
cls = Class.forName( className, true, cl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Method getMainMethod( Class serverClass )
|
|
||||||
{
|
|
||||||
Class argTypes[] = new Class[] { String[].class } ;
|
|
||||||
Method method = null ;
|
|
||||||
|
|
||||||
try {
|
|
||||||
method = serverClass.getDeclaredMethod( "main", argTypes ) ;
|
|
||||||
} catch (Exception exc) {
|
|
||||||
throw new Exception( "Could not get main() method: " + exc ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isPublicStaticVoid( method ))
|
|
||||||
throw new Exception( "Main method is not public static void" ) ;
|
|
||||||
|
|
||||||
return method ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isPublicStaticVoid( Method method )
|
|
||||||
{
|
|
||||||
// check modifiers: public static
|
|
||||||
int modifiers = method.getModifiers ();
|
|
||||||
if (!Modifier.isPublic (modifiers) || !Modifier.isStatic (modifiers)) {
|
|
||||||
logError( method.getName() + " is not public static" ) ;
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check return type and exceptions
|
|
||||||
if (method.getExceptionTypes ().length != 0) {
|
|
||||||
logError( method.getName() + " declares exceptions" ) ;
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!method.getReturnType().equals (Void.TYPE)) {
|
|
||||||
logError( method.getName() + " does not have a void return type" ) ;
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,909 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.presentation.rmi ;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import com.sun.corba.se.spi.presentation.rmi.IDLNameTranslator ;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.presentation.rmi.IDLType ;
|
|
||||||
import com.sun.corba.se.impl.presentation.rmi.IDLTypeException ;
|
|
||||||
import com.sun.corba.se.impl.presentation.rmi.IDLTypesUtil ;
|
|
||||||
import com.sun.corba.se.impl.orbutil.ObjectUtility ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bidirectional translator between RMI-IIOP interface methods and
|
|
||||||
* and IDL Names.
|
|
||||||
*/
|
|
||||||
public class IDLNameTranslatorImpl implements IDLNameTranslator {
|
|
||||||
|
|
||||||
// From CORBA Spec, Table 6 Keywords.
|
|
||||||
// Note that since all IDL identifiers are case
|
|
||||||
// insensitive, java identifier comparisons to these
|
|
||||||
// will be case insensitive also.
|
|
||||||
private static String[] IDL_KEYWORDS = {
|
|
||||||
|
|
||||||
"abstract", "any", "attribute", "boolean", "case", "char",
|
|
||||||
"const", "context", "custom", "default", "double", "enum",
|
|
||||||
"exception", "factory", "FALSE", "fixed", "float", "in", "inout",
|
|
||||||
"interface", "long", "module", "native", "Object", "octet",
|
|
||||||
"oneway", "out", "private", "public", "raises", "readonly", "sequence",
|
|
||||||
"short", "string", "struct", "supports", "switch", "TRUE", "truncatable",
|
|
||||||
"typedef", "unsigned", "union", "ValueBase", "valuetype", "void",
|
|
||||||
"wchar", "wstring"
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
private static char[] HEX_DIGITS = {
|
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
||||||
'A', 'B', 'C', 'D', 'E', 'F'
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final String UNDERSCORE = "_";
|
|
||||||
|
|
||||||
// used to mangle java inner class names
|
|
||||||
private static final String INNER_CLASS_SEPARATOR =
|
|
||||||
UNDERSCORE + UNDERSCORE;
|
|
||||||
|
|
||||||
// used to form IDL array type names
|
|
||||||
private static final String[] BASE_IDL_ARRAY_MODULE_TYPE=
|
|
||||||
new String[] { "org", "omg", "boxedRMI" } ;
|
|
||||||
|
|
||||||
private static final String BASE_IDL_ARRAY_ELEMENT_TYPE = "seq";
|
|
||||||
|
|
||||||
// used to mangling java identifiers that have a leading underscore
|
|
||||||
private static final String LEADING_UNDERSCORE_CHAR = "J";
|
|
||||||
private static final String ID_CONTAINER_CLASH_CHAR = UNDERSCORE;
|
|
||||||
|
|
||||||
// separator used between types in a mangled overloaded method name
|
|
||||||
private static final String OVERLOADED_TYPE_SEPARATOR =
|
|
||||||
UNDERSCORE + UNDERSCORE;
|
|
||||||
|
|
||||||
// string appended to attribute if it clashes with a method name
|
|
||||||
private static final String ATTRIBUTE_METHOD_CLASH_MANGLE_CHARS =
|
|
||||||
UNDERSCORE + UNDERSCORE;
|
|
||||||
|
|
||||||
private static Set idlKeywords_;
|
|
||||||
|
|
||||||
static {
|
|
||||||
|
|
||||||
idlKeywords_ = new HashSet();
|
|
||||||
for(int i = 0; i < IDL_KEYWORDS.length; i++) {
|
|
||||||
String next = (String) IDL_KEYWORDS[i];
|
|
||||||
// Convert keyword to all caps to ease equality
|
|
||||||
// check.
|
|
||||||
String keywordAllCaps = next.toUpperCase();
|
|
||||||
idlKeywords_.add(keywordAllCaps);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Instance state
|
|
||||||
//
|
|
||||||
|
|
||||||
// Remote interface for name translation.
|
|
||||||
private Class[] interf_;
|
|
||||||
|
|
||||||
// Maps used to hold name translations. These do not need to be
|
|
||||||
// synchronized since the translation is never modified after
|
|
||||||
// initialization.
|
|
||||||
private Map methodToIDLNameMap_;
|
|
||||||
private Map IDLNameToMethodMap_;
|
|
||||||
private Method[] methods_;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an IDLNameTranslator for the given interface.
|
|
||||||
*
|
|
||||||
* @throws IllegalStateException if given class is not a valid
|
|
||||||
* RMI/IIOP Remote Interface
|
|
||||||
*/
|
|
||||||
public static IDLNameTranslator get( Class interf )
|
|
||||||
{
|
|
||||||
|
|
||||||
return new IDLNameTranslatorImpl(new Class[] { interf } );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an IDLNameTranslator for the given interfacex.
|
|
||||||
*
|
|
||||||
* @throws IllegalStateException if given classes are not valid
|
|
||||||
* RMI/IIOP Remote Interfaces
|
|
||||||
*/
|
|
||||||
public static IDLNameTranslator get( Class[] interfaces )
|
|
||||||
{
|
|
||||||
|
|
||||||
return new IDLNameTranslatorImpl(interfaces );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getExceptionId( Class cls )
|
|
||||||
{
|
|
||||||
// Requirements for this method:
|
|
||||||
// 1. cls must be an exception but not a RemoteException.
|
|
||||||
// 2. If cls has an IDL keyword name, an underscore is prepended (1.3.2.2).
|
|
||||||
// 3. If cls jas a leading underscore, J is prepended (1.3.2.3).
|
|
||||||
// 4. If cls has an illegal IDL ident char, it is mapped to UXXXX where
|
|
||||||
// XXXX is the unicode value in hex of the char (1.3.2.4).
|
|
||||||
// 5. double underscore for inner class (1.3.2.5).
|
|
||||||
// 6. The ID is "IDL:" + name with / separators + ":1.0".
|
|
||||||
IDLType itype = classToIDLType( cls ) ;
|
|
||||||
return itype.getExceptionName() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class[] getInterfaces()
|
|
||||||
{
|
|
||||||
return interf_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Method[] getMethods()
|
|
||||||
{
|
|
||||||
return methods_ ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Method getMethod( String idlName )
|
|
||||||
{
|
|
||||||
return (Method) IDLNameToMethodMap_.get(idlName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIDLName( Method method )
|
|
||||||
{
|
|
||||||
return (String) methodToIDLNameMap_.get(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize an IDLNameTranslator for the given interface.
|
|
||||||
*
|
|
||||||
* @throws IllegalStateException if given class is not a valid
|
|
||||||
* RMI/IIOP Remote Interface
|
|
||||||
*/
|
|
||||||
private IDLNameTranslatorImpl(Class[] interfaces)
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
|
||||||
IDLTypesUtil idlTypesUtil = new IDLTypesUtil();
|
|
||||||
for (int ctr=0; ctr<interfaces.length; ctr++)
|
|
||||||
idlTypesUtil.validateRemoteInterface(interfaces[ctr]);
|
|
||||||
interf_ = interfaces;
|
|
||||||
buildNameTranslation();
|
|
||||||
} catch( IDLTypeException ite) {
|
|
||||||
String msg = ite.getMessage();
|
|
||||||
IllegalStateException ise = new IllegalStateException(msg);
|
|
||||||
ise.initCause(ite);
|
|
||||||
throw ise;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildNameTranslation()
|
|
||||||
{
|
|
||||||
// holds method info, keyed by method
|
|
||||||
Map allMethodInfo = new HashMap() ;
|
|
||||||
|
|
||||||
for (int ctr=0; ctr<interf_.length; ctr++) {
|
|
||||||
Class interf = interf_[ctr] ;
|
|
||||||
|
|
||||||
IDLTypesUtil idlTypesUtil = new IDLTypesUtil();
|
|
||||||
Method[] methods = interf.getMethods();
|
|
||||||
|
|
||||||
// Take an initial pass through all the methods and create some
|
|
||||||
// information that will be used to track the IDL name
|
|
||||||
// transformation.
|
|
||||||
for(int i = 0; i < methods.length; i++) {
|
|
||||||
|
|
||||||
Method nextMethod = methods[i];
|
|
||||||
|
|
||||||
IDLMethodInfo methodInfo = new IDLMethodInfo();
|
|
||||||
|
|
||||||
methodInfo.method = nextMethod;
|
|
||||||
|
|
||||||
methodInfo.propertyType =
|
|
||||||
idlTypesUtil.propertyAccessorMethodType(
|
|
||||||
nextMethod, interf ) ;
|
|
||||||
|
|
||||||
if (methodInfo.propertyType != null) {
|
|
||||||
String attributeName = idlTypesUtil.
|
|
||||||
getAttributeNameForProperty(nextMethod.getName());
|
|
||||||
methodInfo.originalName = attributeName;
|
|
||||||
methodInfo.mangledName = attributeName;
|
|
||||||
} else {
|
|
||||||
methodInfo.originalName = nextMethod.getName();
|
|
||||||
methodInfo.mangledName = nextMethod.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
allMethodInfo.put(nextMethod, methodInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for having both is<NAME> and get<NAME> methods.
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Perform case sensitivity test first. This applies to all
|
|
||||||
// method names AND attributes. Compare each method name and
|
|
||||||
// attribute to all other method names and attributes. If names
|
|
||||||
// differ only in case, apply mangling as defined in section 1.3.2.7
|
|
||||||
// of Java2IDL spec. Note that we compare using the original names.
|
|
||||||
//
|
|
||||||
for(Iterator outerIter=allMethodInfo.values().iterator();
|
|
||||||
outerIter.hasNext();) {
|
|
||||||
IDLMethodInfo outer = (IDLMethodInfo) outerIter.next();
|
|
||||||
for(Iterator innerIter = allMethodInfo.values().iterator();
|
|
||||||
innerIter.hasNext();) {
|
|
||||||
IDLMethodInfo inner = (IDLMethodInfo) innerIter.next();
|
|
||||||
|
|
||||||
if( (outer != inner) &&
|
|
||||||
(!outer.originalName.equals(inner.originalName)) &&
|
|
||||||
outer.originalName.equalsIgnoreCase(inner.originalName) ) {
|
|
||||||
outer.mangledName =
|
|
||||||
mangleCaseSensitiveCollision(outer.originalName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Iterator iter = allMethodInfo.values().iterator();
|
|
||||||
iter.hasNext();) {
|
|
||||||
IDLMethodInfo next = (IDLMethodcurrentInfo) iter.next();
|
|
||||||
next.mangledName =
|
|
||||||
mangleIdentifier(next.mangledName,
|
|
||||||
next.propertyType != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now check for overloaded method names and apply 1.3.2.6.
|
|
||||||
//
|
|
||||||
for(Iterator outerIter=allMethodInfo.values().iterator();
|
|
||||||
outerIter.hasNext();) {
|
|
||||||
IDLMethodInfo outer = (IDLMethodInfo) outerIter.next();
|
|
||||||
if (outer.propertyType != null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for(Iterator innerIter = allMethodInfo.values().iterator();
|
|
||||||
innerIter.hasNext();) {
|
|
||||||
IDLMethodInfo inner = (IDLMethodInfo) innerIter.next();
|
|
||||||
|
|
||||||
if( (outer != inner) &&
|
|
||||||
(inner.propertyType == null) &&
|
|
||||||
outer.originalName.equals(inner.originalName) ) {
|
|
||||||
outer.mangledName = mangleOverloadedMethod
|
|
||||||
(outer.mangledName, outer.method);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Now mangle any properties that clash with method names.
|
|
||||||
//
|
|
||||||
for(Iterator outerIter=allMethodInfo.values().iterator();
|
|
||||||
outerIter.hasNext();) {
|
|
||||||
IDLMethodInfo outer = (IDLMethodInfo) outerIter.next();
|
|
||||||
if(outer.propertyType == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for(Iterator innerIter = allMethodInfo.values().iterator();
|
|
||||||
innerIter.hasNext();) {
|
|
||||||
IDLMethodInfo inner = (IDLMethodInfo) innerIter.next();
|
|
||||||
if( (outer != inner) &&
|
|
||||||
(inner.propertyType == null) &&
|
|
||||||
outer.mangledName.equals(inner.mangledName) ) {
|
|
||||||
outer.mangledName = outer.mangledName +
|
|
||||||
ATTRIBUTE_METHOD_CLASH_MANGLE_CHARS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Ensure that no mapped method names clash with mapped name
|
|
||||||
// of container(1.3.2.9). This is a case insensitive comparison.
|
|
||||||
//
|
|
||||||
for (int ctr=0; ctr<interf_.length; ctr++ ) {
|
|
||||||
Class interf = interf_[ctr] ;
|
|
||||||
String mappedContainerName = getMappedContainerName(interf);
|
|
||||||
for(Iterator iter = allMethodInfo.values().iterator();
|
|
||||||
iter.hasNext();) {
|
|
||||||
IDLMethodInfo next = (IDLMethodInfo) iter.next();
|
|
||||||
if( (next.propertyType == null) &&
|
|
||||||
identifierClashesWithContainer(mappedContainerName,
|
|
||||||
next.mangledName)) {
|
|
||||||
next.mangledName = mangleContainerClash(next.mangledName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Populate name translation maps.
|
|
||||||
//
|
|
||||||
methodToIDLNameMap_ = new HashMap();
|
|
||||||
IDLNameToMethodMap_ = new HashMap();
|
|
||||||
methods_ = (Method[])allMethodInfo.keySet().toArray(
|
|
||||||
new Method[0] ) ;
|
|
||||||
|
|
||||||
for(Iterator iter = allMethodInfo.values().iterator();
|
|
||||||
iter.hasNext();) {
|
|
||||||
IDLMethodInfo next = (IDLMethodInfo) iter.next();
|
|
||||||
String idlName = next.mangledName;
|
|
||||||
if (next.propertyType != null) {
|
|
||||||
idlName = javaPropertyPrefixToIDL( next.propertyType ) +
|
|
||||||
next.mangledName ;
|
|
||||||
}
|
|
||||||
|
|
||||||
methodToIDLNameMap_.put(next.method, idlName);
|
|
||||||
|
|
||||||
// Final check to see if there are any clashes after all the
|
|
||||||
// manglings have been applied. If so, this is treated as an
|
|
||||||
// invalid interface. Currently, we do a CASE-SENSITIVE
|
|
||||||
// comparison since that matches the rmic behavior.
|
|
||||||
// @@@ Shouldn't this be a case-insensitive check?
|
|
||||||
// If there is a collision between is<TYPE> and get<TYPE>,
|
|
||||||
// map only is<TYPE> to an attribute, and leave the
|
|
||||||
// get<TYPE> method alone.
|
|
||||||
if( IDLNameToMethodMap_.containsKey(idlName) ) {
|
|
||||||
// @@@ I18N
|
|
||||||
Method clash = (Method) IDLNameToMethodMap_.get(idlName);
|
|
||||||
MethodInfo clashMethodInfo =
|
|
||||||
(MethodInfo)allMethodInfo.get( clash ) ;
|
|
||||||
if (clashMethodInfo.isBooleanProperty() &&
|
|
||||||
next.isReadProperty()) {
|
|
||||||
// fix idlName
|
|
||||||
} else if (clashMethodInfo.isReadProperty() &&
|
|
||||||
next.isBooleanProperty()) {
|
|
||||||
// Remove entry under idlName
|
|
||||||
// put entry into table under correct name
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Error : methods " +
|
|
||||||
clash + " and " + next.method +
|
|
||||||
" both result in IDL name '" + idlName + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IDLNameToMethodMap_.put(idlName, next.method);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Perform all necessary stand-alone identifier mangling operations
|
|
||||||
* on a java identifier that is being transformed into an IDL name.
|
|
||||||
* That is, mangling operations that don't require looking at anything
|
|
||||||
* else but the identifier itself. This covers sections 1.3.2.2, 1.3.2.3,
|
|
||||||
* and 1.3.2.4 of the Java2IDL spec. Method overloading and
|
|
||||||
* case-sensitivity checks are handled elsewhere.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private static String mangleIdentifier(String identifier) {
|
|
||||||
return mangleIdentifier(identifier, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String mangleIdentifier(String identifier, boolean attribute) {
|
|
||||||
|
|
||||||
String mangledName = identifier;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Apply leading underscore test (1.3.2.3)
|
|
||||||
// This should be done before IDL Keyword clash test, since clashing
|
|
||||||
// IDL keywords are mangled by adding a leading underscore.
|
|
||||||
//
|
|
||||||
if( hasLeadingUnderscore(mangledName) ) {
|
|
||||||
mangledName = mangleLeadingUnderscore(mangledName);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Apply IDL keyword clash test (1.3.2.2).
|
|
||||||
// This is not needed for attributes since when the full property
|
|
||||||
// name is composed it cannot clash with an IDL keyword.
|
|
||||||
// (Also, rmic doesn't do it.)
|
|
||||||
//
|
|
||||||
|
|
||||||
if( !attribute && isIDLKeyword(mangledName) ) {
|
|
||||||
mangledName = mangleIDLKeywordClash(mangledName);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Replace illegal IDL identifier characters (1.3.2.4)
|
|
||||||
// for all method names and attributes.
|
|
||||||
//
|
|
||||||
if( !isIDLIdentifier(mangledName) ) {
|
|
||||||
mangledName = mangleUnicodeChars(mangledName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mangledName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether a java identifier clashes with an
|
|
||||||
* IDL keyword. Note that this is a case-insensitive
|
|
||||||
* comparison.
|
|
||||||
*
|
|
||||||
* Used to implement section 1.3.2.2 of Java2IDL spec.
|
|
||||||
*/
|
|
||||||
private static boolean isIDLKeyword(String identifier) {
|
|
||||||
|
|
||||||
String identifierAllCaps = identifier.toUpperCase();
|
|
||||||
|
|
||||||
return idlKeywords_.contains(identifierAllCaps);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String mangleIDLKeywordClash(String identifier) {
|
|
||||||
return UNDERSCORE + identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String mangleLeadingUnderscore(String identifier) {
|
|
||||||
return LEADING_UNDERSCORE_CHAR + identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether a java identifier starts with an underscore.
|
|
||||||
* Used to implement section 1.3.2.3 of Java2IDL spec.
|
|
||||||
*/
|
|
||||||
private static boolean hasLeadingUnderscore(String identifier) {
|
|
||||||
return identifier.startsWith(UNDERSCORE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements Section 1.3.2.4 of Java2IDL Mapping.
|
|
||||||
* All non-IDL identifier characters must be replaced
|
|
||||||
* with their Unicode representation.
|
|
||||||
*/
|
|
||||||
static String mangleUnicodeChars(String identifier) {
|
|
||||||
StringBuffer mangledIdentifier = new StringBuffer();
|
|
||||||
|
|
||||||
for(int i = 0; i < identifier.length(); i++) {
|
|
||||||
char nextChar = identifier.charAt(i);
|
|
||||||
if( isIDLIdentifierChar(nextChar) ) {
|
|
||||||
mangledIdentifier.append(nextChar);
|
|
||||||
} else {
|
|
||||||
String unicode = charToUnicodeRepresentation(nextChar);
|
|
||||||
mangledIdentifier.append(unicode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mangledIdentifier.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements mangling portion of Section 1.3.2.7 of Java2IDL spec.
|
|
||||||
* This method only deals with the actual mangling. Decision about
|
|
||||||
* whether case-sensitive collision mangling is required is made
|
|
||||||
* elsewhere.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* "...a mangled name is generated consisting of the original name
|
|
||||||
* followed by an underscore separated list of decimal indices
|
|
||||||
* into the string, where the indices identify all the upper case
|
|
||||||
* characters in the original string. Indices are zero based."
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
String mangleCaseSensitiveCollision(String identifier) {
|
|
||||||
|
|
||||||
StringBuffer mangledIdentifier = new StringBuffer(identifier);
|
|
||||||
|
|
||||||
// There is always at least one trailing underscore, whether or
|
|
||||||
// not the identifier has uppercase letters.
|
|
||||||
mangledIdentifier.append(UNDERSCORE);
|
|
||||||
|
|
||||||
boolean needUnderscore = false;
|
|
||||||
for(int i = 0; i < identifier.length(); i++) {
|
|
||||||
char next = identifier.charAt(i);
|
|
||||||
if( Character.isUpperCase(next) ) {
|
|
||||||
// This bit of logic is needed to ensure that we have
|
|
||||||
// an underscore separated list of indices but no
|
|
||||||
// trailing underscores. Basically, after we have at least
|
|
||||||
// one uppercase letter, we always put an undercore before
|
|
||||||
// printing the next one.
|
|
||||||
if( needUnderscore ) {
|
|
||||||
mangledIdentifier.append(UNDERSCORE);
|
|
||||||
}
|
|
||||||
mangledIdentifier.append(i);
|
|
||||||
needUnderscore = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mangledIdentifier.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String mangleContainerClash(String identifier) {
|
|
||||||
return identifier + ID_CONTAINER_CLASH_CHAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements Section 1.3.2.9 of Java2IDL Mapping. Container in this
|
|
||||||
* context means the name of the java Class(excluding package) in which
|
|
||||||
* the identifier is defined. Comparison is case-insensitive.
|
|
||||||
*/
|
|
||||||
private static boolean identifierClashesWithContainer
|
|
||||||
(String mappedContainerName, String identifier) {
|
|
||||||
|
|
||||||
return identifier.equalsIgnoreCase(mappedContainerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns Unicode mangling as defined in Section 1.3.2.4 of
|
|
||||||
* Java2IDL spec.
|
|
||||||
*
|
|
||||||
* "For Java identifiers that contain illegal OMG IDL identifier
|
|
||||||
* characters such as '$' or Unicode characters outside of ISO Latin 1,
|
|
||||||
* any such illegal characters are replaced by "U" followed by the
|
|
||||||
* 4 hexadecimal characters(in upper case) representing the Unicode
|
|
||||||
* value. So, the Java name a$b is mapped to aU0024b and
|
|
||||||
* x\u03bCy is mapped to xU03BCy."
|
|
||||||
*/
|
|
||||||
public static String charToUnicodeRepresentation(char c) {
|
|
||||||
|
|
||||||
int orig = (int) c;
|
|
||||||
StringBuffer hexString = new StringBuffer();
|
|
||||||
|
|
||||||
int value = orig;
|
|
||||||
|
|
||||||
while( value > 0 ) {
|
|
||||||
int div = value / 16;
|
|
||||||
int mod = value % 16;
|
|
||||||
hexString.insert(0, HEX_DIGITS[mod]);
|
|
||||||
value = div;
|
|
||||||
}
|
|
||||||
|
|
||||||
int numZerosToAdd = 4 - hexString.length();
|
|
||||||
for(int i = 0; i < numZerosToAdd; i++) {
|
|
||||||
hexString.insert(0, "0");
|
|
||||||
}
|
|
||||||
|
|
||||||
hexString.insert(0, "U");
|
|
||||||
return hexString.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isIDLIdentifier(String identifier) {
|
|
||||||
|
|
||||||
boolean isIdentifier = true;
|
|
||||||
|
|
||||||
for(int i = 0; i < identifier.length(); i++) {
|
|
||||||
char nextChar = identifier.charAt(i);
|
|
||||||
// 1st char must be alphbetic.
|
|
||||||
isIdentifier = (i == 0) ?
|
|
||||||
isIDLAlphabeticChar(nextChar) :
|
|
||||||
isIDLIdentifierChar(nextChar);
|
|
||||||
if( !isIdentifier ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isIdentifier;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isIDLIdentifierChar(char c) {
|
|
||||||
return (isIDLAlphabeticChar(c) ||
|
|
||||||
isIDLDecimalDigit(c) ||
|
|
||||||
isUnderscore(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* True if character is one of 114 Alphabetic characters as
|
|
||||||
* specified in Table 2 of Chapter 3 in CORBA spec.
|
|
||||||
*/
|
|
||||||
private static boolean isIDLAlphabeticChar(char c) {
|
|
||||||
|
|
||||||
// NOTE that we can't use the java.lang.Character
|
|
||||||
// isUpperCase, isLowerCase, etc. methods since they
|
|
||||||
// include many characters other than the Alphabetic list in
|
|
||||||
// the CORBA spec. Instead, we test for inclusion in the
|
|
||||||
// Unicode value ranges for the corresponding legal characters.
|
|
||||||
|
|
||||||
boolean alphaChar =
|
|
||||||
(
|
|
||||||
// A - Z
|
|
||||||
((c >= 0x0041) && (c <= 0x005A))
|
|
||||||
|
|
||||||
||
|
|
||||||
|
|
||||||
// a - z
|
|
||||||
((c >= 0x0061) && (c <= 0x007A))
|
|
||||||
|
|
||||||
||
|
|
||||||
|
|
||||||
// other letter uppercase, other letter lowercase, which is
|
|
||||||
// the entire upper half of C1 Controls except X and /
|
|
||||||
((c >= 0x00C0) && (c <= 0x00FF)
|
|
||||||
&& (c != 0x00D7) && (c != 0x00F7)));
|
|
||||||
|
|
||||||
return alphaChar;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* True if character is one of 10 Decimal Digits
|
|
||||||
* specified in Table 3 of Chapter 3 in CORBA spec.
|
|
||||||
*/
|
|
||||||
private static boolean isIDLDecimalDigit(char c) {
|
|
||||||
return ( (c >= 0x0030) && (c <= 0x0039) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isUnderscore(char c) {
|
|
||||||
return ( c == 0x005F );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mangle an overloaded method name as defined in Section 1.3.2.6 of
|
|
||||||
* Java2IDL spec. Current value of method name is passed in as argument.
|
|
||||||
* We can't start from original method name since the name might have
|
|
||||||
* been partially mangled as a result of the other rules.
|
|
||||||
*/
|
|
||||||
private static String mangleOverloadedMethod(String mangledName, Method m) {
|
|
||||||
|
|
||||||
IDLTypesUtil idlTypesUtil = new IDLTypesUtil();
|
|
||||||
|
|
||||||
// Start by appending the separator string
|
|
||||||
String newMangledName = mangledName + OVERLOADED_TYPE_SEPARATOR;
|
|
||||||
|
|
||||||
Class[] parameterTypes = m.getParameterTypes();
|
|
||||||
|
|
||||||
for(int i = 0; i < parameterTypes.length; i++) {
|
|
||||||
Class nextParamType = parameterTypes[i];
|
|
||||||
|
|
||||||
if( i > 0 ) {
|
|
||||||
newMangledName = newMangledName + OVERLOADED_TYPE_SEPARATOR;
|
|
||||||
}
|
|
||||||
IDLType idlType = classToIDLType(nextParamType);
|
|
||||||
|
|
||||||
String moduleName = idlType.getModuleName();
|
|
||||||
String memberName = idlType.getMemberName();
|
|
||||||
|
|
||||||
String typeName = (moduleName.length() > 0) ?
|
|
||||||
moduleName + UNDERSCORE + memberName : memberName;
|
|
||||||
|
|
||||||
if( !idlTypesUtil.isPrimitive(nextParamType) &&
|
|
||||||
(idlTypesUtil.getSpecialCaseIDLTypeMapping(nextParamType)
|
|
||||||
== null) &&
|
|
||||||
isIDLKeyword(typeName) ) {
|
|
||||||
typeName = mangleIDLKeywordClash(typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
typeName = mangleUnicodeChars(typeName);
|
|
||||||
|
|
||||||
newMangledName = newMangledName + typeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newMangledName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static IDLType classToIDLType(Class c) {
|
|
||||||
|
|
||||||
IDLType idlType = null;
|
|
||||||
IDLTypesUtil idlTypesUtil = new IDLTypesUtil();
|
|
||||||
|
|
||||||
if( idlTypesUtil.isPrimitive(c) ) {
|
|
||||||
|
|
||||||
idlType = idlTypesUtil.getPrimitiveIDLTypeMapping(c);
|
|
||||||
|
|
||||||
} else if( c.isArray() ) {
|
|
||||||
|
|
||||||
// Calculate array depth, as well as base element type.
|
|
||||||
Class componentType = c.getComponentType();
|
|
||||||
int numArrayDimensions = 1;
|
|
||||||
while(componentType.isArray()) {
|
|
||||||
componentType = componentType.getComponentType();
|
|
||||||
numArrayDimensions++;
|
|
||||||
}
|
|
||||||
IDLType componentIdlType = classToIDLType(componentType);
|
|
||||||
|
|
||||||
String[] modules = BASE_IDL_ARRAY_MODULE_TYPE;
|
|
||||||
if( componentIdlType.hasModule() ) {
|
|
||||||
modules = (String[])ObjectUtility.concatenateArrays( modules,
|
|
||||||
componentIdlType.getModules() ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
String memberName = BASE_IDL_ARRAY_ELEMENT_TYPE +
|
|
||||||
numArrayDimensions + UNDERSCORE +
|
|
||||||
componentIdlType.getMemberName();
|
|
||||||
|
|
||||||
idlType = new IDLType(c, modules, memberName);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
idlType = idlTypesUtil.getSpecialCaseIDLTypeMapping(c);
|
|
||||||
|
|
||||||
if (idlType == null) {
|
|
||||||
// Section 1.3.2.5 of Java2IDL spec defines mangling rules for
|
|
||||||
// inner classes.
|
|
||||||
String memberName = getUnmappedContainerName(c);
|
|
||||||
|
|
||||||
// replace inner class separator with double underscore
|
|
||||||
memberName = memberName.replaceAll("\\$",
|
|
||||||
INNER_CLASS_SEPARATOR);
|
|
||||||
|
|
||||||
if( hasLeadingUnderscore(memberName) ) {
|
|
||||||
memberName = mangleLeadingUnderscore(memberName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get raw package name. If there is a package, it
|
|
||||||
// will still have the "." separators and none of the
|
|
||||||
// mangling rules will have been applied.
|
|
||||||
String packageName = getPackageName(c);
|
|
||||||
|
|
||||||
if (packageName == null) {
|
|
||||||
idlType = new IDLType( c, memberName ) ;
|
|
||||||
} else {
|
|
||||||
// If this is a generated IDL Entity Type we need to
|
|
||||||
// prepend org_omg_boxedIDL per sections 1.3.5 and 1.3.9
|
|
||||||
if (idlTypesUtil.isEntity(c)) {
|
|
||||||
packageName = "org.omg.boxedIDL." + packageName ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Section 1.3.2.1 and 1.3.2.6 of Java2IDL spec defines
|
|
||||||
// rules for mapping java packages to IDL modules and for
|
|
||||||
// mangling module name portion of type name. NOTE that
|
|
||||||
// of the individual identifier mangling rules,
|
|
||||||
// only the leading underscore test is done here.
|
|
||||||
// The other two(IDL Keyword, Illegal Unicode chars) are
|
|
||||||
// done in mangleOverloadedMethodName.
|
|
||||||
StringTokenizer tokenizer =
|
|
||||||
new StringTokenizer(packageName, ".");
|
|
||||||
|
|
||||||
String[] modules = new String[ tokenizer.countTokens() ] ;
|
|
||||||
int index = 0 ;
|
|
||||||
while (tokenizer.hasMoreElements()) {
|
|
||||||
String next = tokenizer.nextToken();
|
|
||||||
String nextMangled = hasLeadingUnderscore(next) ?
|
|
||||||
mangleLeadingUnderscore(next) : next;
|
|
||||||
|
|
||||||
modules[index++] = nextMangled ;
|
|
||||||
}
|
|
||||||
|
|
||||||
idlType = new IDLType(c, modules, memberName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return idlType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return Class' package name or null if there is no package.
|
|
||||||
*/
|
|
||||||
private static String getPackageName(Class c) {
|
|
||||||
Package thePackage = c.getPackage();
|
|
||||||
String packageName = null;
|
|
||||||
|
|
||||||
// Try to get package name by introspection. Some classloaders might
|
|
||||||
// not provide this information, so check for null.
|
|
||||||
if( thePackage != null ) {
|
|
||||||
packageName = thePackage.getName();
|
|
||||||
} else {
|
|
||||||
// brute force method
|
|
||||||
String fullyQualifiedClassName = c.getName();
|
|
||||||
int lastDot = fullyQualifiedClassName.indexOf('.');
|
|
||||||
packageName = (lastDot == -1) ? null :
|
|
||||||
fullyQualifiedClassName.substring(0, lastDot);
|
|
||||||
}
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getMappedContainerName(Class c) {
|
|
||||||
String unmappedName = getUnmappedContainerName(c);
|
|
||||||
|
|
||||||
return mangleIdentifier(unmappedName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return portion of class name excluding package name.
|
|
||||||
*/
|
|
||||||
private static String getUnmappedContainerName(Class c) {
|
|
||||||
|
|
||||||
String memberName = null;
|
|
||||||
String packageName = getPackageName(c);
|
|
||||||
|
|
||||||
String fullyQualifiedClassName = c.getName();
|
|
||||||
|
|
||||||
if( packageName != null ) {
|
|
||||||
int packageLength = packageName.length();
|
|
||||||
memberName = fullyQualifiedClassName.substring(packageLength + 1);
|
|
||||||
} else {
|
|
||||||
memberName = fullyQualifiedClassName;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return memberName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal helper class for tracking information related to each
|
|
||||||
* interface method while we're building the name translation table.
|
|
||||||
*/
|
|
||||||
private static class IDLMethodInfo
|
|
||||||
{
|
|
||||||
public Method method;
|
|
||||||
public String propertyType;
|
|
||||||
|
|
||||||
// If this is a property, originalName holds the original
|
|
||||||
// attribute name. Otherwise, it holds the original method name.
|
|
||||||
public String originalName;
|
|
||||||
|
|
||||||
// If this is a property, mangledName holds the mangled attribute
|
|
||||||
// name. Otherwise, it holds the mangled method name.
|
|
||||||
public String mangledName;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
|
|
||||||
StringBuffer contents = new StringBuffer();
|
|
||||||
contents.append("IDLNameTranslator[" );
|
|
||||||
for( int ctr=0; ctr<interf_.length; ctr++) {
|
|
||||||
if (ctr != 0)
|
|
||||||
contents.append( " " ) ;
|
|
||||||
contents.append( interf_[ctr].getName() ) ;
|
|
||||||
}
|
|
||||||
contents.append("]\n");
|
|
||||||
for(Iterator iter = methodToIDLNameMap_.keySet().iterator();
|
|
||||||
iter.hasNext();) {
|
|
||||||
|
|
||||||
Method method = (Method) iter.next();
|
|
||||||
String idlName = (String) methodToIDLNameMap_.get(method);
|
|
||||||
|
|
||||||
contents.append(idlName + ":" + method + "\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return contents.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
Class remoteInterface = java.rmi.Remote.class;
|
|
||||||
|
|
||||||
if( args.length > 0 ) {
|
|
||||||
String className = args[0];
|
|
||||||
try {
|
|
||||||
remoteInterface = Class.forName(className);
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Building name translation for " + remoteInterface);
|
|
||||||
try {
|
|
||||||
IDLNameTranslator nameTranslator =
|
|
||||||
IDLNameTranslatorImpl.get(remoteInterface);
|
|
||||||
System.out.println(nameTranslator);
|
|
||||||
} catch(IllegalStateException ise) {
|
|
||||||
ise.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,544 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.presentation.rmi ;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility class for testing RMI/IDL Types as defined in
|
|
||||||
* Section 1.2 of The Java Language to IDL Mapping. Note that
|
|
||||||
* these are static checks only. Runtime checks, such as those
|
|
||||||
* described in Section 1.2.3, #3, are not covered.
|
|
||||||
*/
|
|
||||||
public class IDLTypesUtil {
|
|
||||||
|
|
||||||
public static final String JAVA_GET_PROPERTY_PREFIX = "get";
|
|
||||||
public static final String JAVA_SET_PROPERTY_PREFIX = "set";
|
|
||||||
public static final String JAVA_IS_PROPERTY_PREFIX = "is";
|
|
||||||
|
|
||||||
public static final int VALID_TYPE = 0;
|
|
||||||
public static final int INVALID_TYPE = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate a class to ensure it conforms to the rules for a
|
|
||||||
* Java RMI/IIOP interface.
|
|
||||||
*
|
|
||||||
* @throws IDLTypeException if not a valid RMI/IIOP interface.
|
|
||||||
*/
|
|
||||||
public void validateRemoteInterface(Class c) throws IDLTypeException
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !c.isInterface() ) {
|
|
||||||
String msg = "Class " + c + " must be a java interface.";
|
|
||||||
throw new IDLTypeException(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !java.rmi.Remote.class.isAssignableFrom(c) ) {
|
|
||||||
String msg = "Class " + c + " must extend java.rmi.Remote, " +
|
|
||||||
"either directly or indirectly.";
|
|
||||||
throw new IDLTypeException(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all methods, including super-interface methods.
|
|
||||||
Method[] methods = c.getMethods();
|
|
||||||
|
|
||||||
for(int i = 0; i < methods.length; i++) {
|
|
||||||
Method next = methods[i];
|
|
||||||
validateExceptions(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Removed because of bug 4989053
|
|
||||||
// validateDirectInterfaces(c);
|
|
||||||
validateConstants(c);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRemoteInterface(Class c)
|
|
||||||
{
|
|
||||||
boolean remoteInterface = true;
|
|
||||||
try {
|
|
||||||
validateRemoteInterface(c);
|
|
||||||
} catch(IDLTypeException ite) {
|
|
||||||
remoteInterface = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return remoteInterface;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section 1.2.2 Primitive Types
|
|
||||||
*/
|
|
||||||
public boolean isPrimitive(Class c)
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.isPrimitive();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section 1.2.4
|
|
||||||
*/
|
|
||||||
public boolean isValue(Class c)
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
(!c.isInterface() &&
|
|
||||||
java.io.Serializable.class.isAssignableFrom(c) &&
|
|
||||||
!java.rmi.Remote.class.isAssignableFrom(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section 1.2.5
|
|
||||||
*/
|
|
||||||
public boolean isArray(Class c)
|
|
||||||
{
|
|
||||||
boolean arrayType = false;
|
|
||||||
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( c.isArray() ) {
|
|
||||||
Class componentType = c.getComponentType();
|
|
||||||
arrayType =
|
|
||||||
(isPrimitive(componentType) || isRemoteInterface(componentType) ||
|
|
||||||
isEntity(componentType) || isException(componentType) ||
|
|
||||||
isValue(componentType) || isObjectReference(componentType) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return arrayType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section 1.2.6
|
|
||||||
*/
|
|
||||||
public boolean isException(Class c)
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must be a checked exception, not including RemoteException or
|
|
||||||
// its subclasses.
|
|
||||||
return isCheckedException(c) && !isRemoteException(c) && isValue(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRemoteException(Class c)
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return java.rmi.RemoteException.class.isAssignableFrom(c) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCheckedException(Class c)
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Throwable.class.isAssignableFrom(c) &&
|
|
||||||
!RuntimeException.class.isAssignableFrom(c) &&
|
|
||||||
!Error.class.isAssignableFrom(c) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section 1.2.7
|
|
||||||
*/
|
|
||||||
public boolean isObjectReference(Class c)
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (c.isInterface() &&
|
|
||||||
org.omg.CORBA.Object.class.isAssignableFrom(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Section 1.2.8
|
|
||||||
*/
|
|
||||||
public boolean isEntity(Class c)
|
|
||||||
{
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
Class superClass = c.getSuperclass();
|
|
||||||
return (!c.isInterface() &&
|
|
||||||
(superClass != null) &&
|
|
||||||
(org.omg.CORBA.portable.IDLEntity.class.isAssignableFrom(c)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String javaPropertyPrefixToIDL( String javaPrefix )
|
|
||||||
{
|
|
||||||
return "_" + javaPrefix + "_" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the property type if given method is legal property accessor as defined in
|
|
||||||
* Section 1.3.4.3 of Java2IDL spec. Result is one of: JAVA_GET_PROPERTY_PREFIX,
|
|
||||||
* JAVA_SET_PROPERTY_PREFIX, JAVA_IS_PROPERTY_PREFIX.
|
|
||||||
*/
|
|
||||||
public String propertyAccessorMethodType(Method m, Class c) {
|
|
||||||
|
|
||||||
String methodName = m.getName();
|
|
||||||
Class returnType = m.getReturnType();
|
|
||||||
Class[] parameters = m.getParameterTypes();
|
|
||||||
Class[] exceptionTypes = m.getExceptionTypes();
|
|
||||||
String propertyType = null;
|
|
||||||
|
|
||||||
if( methodName.startsWith(JAVA_GET_PROPERTY_PREFIX) ) {
|
|
||||||
|
|
||||||
if((parameters.length == 0) && (returnType != Void.TYPE) &&
|
|
||||||
!hasCorrespondingReadProperty(m, c, JAVA_IS_PROPERTY_PREFIX) {
|
|
||||||
propertyType = JAVA_GET_PROPERTY_PREFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if( methodName.startsWith(JAVA_SET_PROPERTY_PREFIX) ) {
|
|
||||||
|
|
||||||
if((returnType == Void.TYPE) && (parameters.length == 1)) {
|
|
||||||
if (hasCorrespondingReadProperty(m, c, JAVA_GET_PROPERTY_PREFIX) ||
|
|
||||||
hasCorrespondingReadProperty(m, c, JAVA_IS_PROPERTY_PREFIX)) {
|
|
||||||
propertyType = JAVA_SET_PROPERTY_PREFIX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if( methodName.startsWith(JAVA_IS_PROPERTY_PREFIX) ) {
|
|
||||||
if((parameters.length == 0) && (returnType == Boolean.TYPE)) {
|
|
||||||
propertyType = JAVA_IS_PROPERTY_PREFIX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some final checks that apply to all properties.
|
|
||||||
if( propertyType != null ) {
|
|
||||||
if(!validPropertyExceptions(m) ||
|
|
||||||
(methodName.length() <= propertyType.length())) {
|
|
||||||
propertyType = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return propertyType ;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasCorrespondingReadProperty
|
|
||||||
(Method writeProperty, Class c, String readPropertyPrefix) {
|
|
||||||
|
|
||||||
String writePropertyMethodName = writeProperty.getName();
|
|
||||||
Class[] writePropertyParameters = writeProperty.getParameterTypes();
|
|
||||||
boolean foundReadProperty = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Look for a valid corresponding Read property
|
|
||||||
String readPropertyMethodName =
|
|
||||||
writePropertyMethodName.replaceFirst
|
|
||||||
(JAVA_SET_PROPERTY_PREFIX, readPropertyPrefix);
|
|
||||||
Method readPropertyMethod = c.getMethod(readPropertyMethodName,
|
|
||||||
new Class[] {});
|
|
||||||
foundReadProperty =
|
|
||||||
((propertyAccessorMethodType(readPropertyMethod, c) != null) &&
|
|
||||||
(readPropertyMethod.getReturnType() ==
|
|
||||||
writePropertyParameters[0]));
|
|
||||||
} catch(Exception e) {
|
|
||||||
// ignore. this means we didn't find a corresponding get property.
|
|
||||||
}
|
|
||||||
|
|
||||||
return foundReadProperty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAttributeNameForProperty(String propertyName) {
|
|
||||||
String attributeName = null;
|
|
||||||
String prefix = null;
|
|
||||||
|
|
||||||
if( propertyName.startsWith(JAVA_GET_PROPERTY_PREFIX) ) {
|
|
||||||
prefix = JAVA_GET_PROPERTY_PREFIX;
|
|
||||||
} else if( propertyName.startsWith(JAVA_SET_PROPERTY_PREFIX) ) {
|
|
||||||
prefix = JAVA_SET_PROPERTY_PREFIX;
|
|
||||||
} else if( propertyName.startsWith(JAVA_IS_PROPERTY_PREFIX) ) {
|
|
||||||
prefix = JAVA_IS_PROPERTY_PREFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (prefix != null) && (prefix.length() < propertyName.length()) ) {
|
|
||||||
String remainder = propertyName.substring(prefix.length());
|
|
||||||
if( (remainder.length() >= 2) &&
|
|
||||||
Character.isUpperCase(remainder.charAt(0)) &&
|
|
||||||
Character.isUpperCase(remainder.charAt(1)) ) {
|
|
||||||
// don't set the first letter to lower-case if the
|
|
||||||
// first two are upper-case
|
|
||||||
attributeName = remainder;
|
|
||||||
} else {
|
|
||||||
attributeName = Character.toLowerCase(remainder.charAt(0)) +
|
|
||||||
remainder.substring(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return attributeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return IDL Type name for primitive types as defined in
|
|
||||||
* Section 1.3.3 of Java2IDL spec or null if not a primitive type.
|
|
||||||
*/
|
|
||||||
public IDLType getPrimitiveIDLTypeMapping(Class c) {
|
|
||||||
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( c.isPrimitive() ) {
|
|
||||||
if( c == Void.TYPE ) {
|
|
||||||
return new IDLType( c, "void" ) ;
|
|
||||||
} else if( c == Boolean.TYPE ) {
|
|
||||||
return new IDLType( c, "boolean" ) ;
|
|
||||||
} else if( c == Character.TYPE ) {
|
|
||||||
return new IDLType( c, "wchar" ) ;
|
|
||||||
} else if( c == Byte.TYPE ) {
|
|
||||||
return new IDLType( c, "octet" ) ;
|
|
||||||
} else if( c == Short.TYPE ) {
|
|
||||||
return new IDLType( c, "short" ) ;
|
|
||||||
} else if( c == Integer.TYPE ) {
|
|
||||||
return new IDLType( c, "long" ) ;
|
|
||||||
} else if( c == Long.TYPE ) {
|
|
||||||
return new IDLType( c, "long_long" ) ;
|
|
||||||
} else if( c == Float.TYPE ) {
|
|
||||||
return new IDLType( c, "float" ) ;
|
|
||||||
} else if( c == Double.TYPE ) {
|
|
||||||
return new IDLType( c, "double" ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return IDL Type name for special case type mappings as defined in
|
|
||||||
* Table 1-1 of Java2IDL spec or null if given class is not a special
|
|
||||||
* type.
|
|
||||||
*/
|
|
||||||
public IDLType getSpecialCaseIDLTypeMapping(Class c) {
|
|
||||||
|
|
||||||
if( c == null ) {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( c == java.lang.Object.class ) {
|
|
||||||
return new IDLType( c, new String[] { "java", "lang" },
|
|
||||||
"Object" ) ;
|
|
||||||
} else if( c == java.lang.String.class ) {
|
|
||||||
return new IDLType( c, new String[] { "CORBA" },
|
|
||||||
"WStringValue" ) ;
|
|
||||||
} else if( c == java.lang.Class.class ) {
|
|
||||||
return new IDLType( c, new String[] { "javax", "rmi", "CORBA" },
|
|
||||||
"ClassDesc" ) ;
|
|
||||||
} else if( c == java.io.Serializable.class ) {
|
|
||||||
return new IDLType( c, new String[] { "java", "io" },
|
|
||||||
"Serializable" ) ;
|
|
||||||
} else if( c == java.io.Externalizable.class ) {
|
|
||||||
return new IDLType( c, new String[] { "java", "io" },
|
|
||||||
"Externalizable" ) ;
|
|
||||||
} else if( c == java.rmi.Remote.class ) {
|
|
||||||
return new IDLType( c, new String[] { "java", "rmi" },
|
|
||||||
"Remote" ) ;
|
|
||||||
} else if( c == org.omg.CORBA.Object.class ) {
|
|
||||||
return new IDLType( c, "Object" ) ;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements 1.2.3 #2 and #4
|
|
||||||
*/
|
|
||||||
private void validateExceptions(Method method) throws IDLTypeException {
|
|
||||||
|
|
||||||
Class[] exceptions = method.getExceptionTypes();
|
|
||||||
|
|
||||||
boolean declaresRemoteExceptionOrSuperClass = false;
|
|
||||||
|
|
||||||
// Section 1.2.3, #2
|
|
||||||
for(int eIndex = 0; eIndex < exceptions.length; eIndex++) {
|
|
||||||
Class exception = exceptions[eIndex];
|
|
||||||
if( isRemoteExceptionOrSuperClass(exception) ) {
|
|
||||||
declaresRemoteExceptionOrSuperClass = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !declaresRemoteExceptionOrSuperClass ) {
|
|
||||||
String msg = "Method '" + method + "' must throw at least one " +
|
|
||||||
"exception of type java.rmi.RemoteException or one of its " +
|
|
||||||
"super-classes";
|
|
||||||
throw new IDLTypeException(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Section 1.2.3, #4
|
|
||||||
// See also bug 4972402
|
|
||||||
// For all exceptions E in exceptions,
|
|
||||||
// (isCheckedException(E) => (isValue(E) || RemoteException.isAssignableFrom( E ) )
|
|
||||||
for(int eIndex = 0; eIndex < exceptions.length; eIndex++) {
|
|
||||||
Class exception = exceptions[eIndex];
|
|
||||||
|
|
||||||
if (isCheckedException(exception) && !isValue(exception) &&
|
|
||||||
!isRemoteException(exception))
|
|
||||||
{
|
|
||||||
String msg = "Exception '" + exception + "' on method '" +
|
|
||||||
method + "' is not a allowed RMI/IIOP exception type";
|
|
||||||
throw new IDLTypeException(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the method's throw clause conforms to the exception
|
|
||||||
* restrictions for properties as defined in Section 1.3.4.3 of
|
|
||||||
* Java2IDL spec. This means that for all exceptions E declared on the
|
|
||||||
* method, E isChecked => RemoteException.isAssignableFrom( E ).
|
|
||||||
*/
|
|
||||||
private boolean validPropertyExceptions(Method method)
|
|
||||||
{
|
|
||||||
Class[] exceptions = method.getExceptionTypes();
|
|
||||||
|
|
||||||
for(int eIndex = 0; eIndex < exceptions.length; eIndex++) {
|
|
||||||
Class exception = exceptions[eIndex];
|
|
||||||
|
|
||||||
if (isCheckedException(exception) && !isRemoteException(exception))
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements Section 1.2.3, #2.
|
|
||||||
*/
|
|
||||||
private boolean isRemoteExceptionOrSuperClass(Class c) {
|
|
||||||
return
|
|
||||||
((c == java.rmi.RemoteException.class) ||
|
|
||||||
(c == java.io.IOException.class) ||
|
|
||||||
(c == java.lang.Exception.class) ||
|
|
||||||
(c == java.lang.Throwable.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements Section 1.2.3, #5.
|
|
||||||
*/
|
|
||||||
private void validateDirectInterfaces(Class c) throws IDLTypeException {
|
|
||||||
|
|
||||||
Class[] directInterfaces = c.getInterfaces();
|
|
||||||
|
|
||||||
if( directInterfaces.length < 2 ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set allMethodNames = new HashSet();
|
|
||||||
Set currentMethodNames = new HashSet();
|
|
||||||
|
|
||||||
for(int i = 0; i < directInterfaces.length; i++) {
|
|
||||||
Class next = directInterfaces[i];
|
|
||||||
Method[] methods = next.getMethods();
|
|
||||||
|
|
||||||
// Comparison is based on method names only. First collect
|
|
||||||
// all methods from current interface, eliminating duplicate
|
|
||||||
// names.
|
|
||||||
currentMethodNames.clear();
|
|
||||||
for(int m = 0; m < methods.length; m++) {
|
|
||||||
currentMethodNames.add(methods[m].getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now check each method against list of all unique method
|
|
||||||
// names processed so far.
|
|
||||||
for(Iterator iter=currentMethodNames.iterator(); iter.hasNext();) {
|
|
||||||
String methodName = (String) iter.next();
|
|
||||||
if( allMethodNames.contains(methodName) ) {
|
|
||||||
String msg = "Class " + c + " inherits method " +
|
|
||||||
methodName + " from multiple direct interfaces.";
|
|
||||||
throw new IDLTypeException(msg);
|
|
||||||
} else {
|
|
||||||
allMethodNames.add(methodName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements 1.2.3 #6
|
|
||||||
*/
|
|
||||||
private void validateConstants(final Class c)
|
|
||||||
throws IDLTypeException {
|
|
||||||
|
|
||||||
Field[] fields = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
fields = (Field[])
|
|
||||||
java.security.AccessController.doPrivileged
|
|
||||||
(new java.security.PrivilegedExceptionAction() {
|
|
||||||
public java.lang.Object run() throws Exception {
|
|
||||||
return c.getFields();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch(java.security.PrivilegedActionException pae) {
|
|
||||||
IDLTypeException ite = new IDLTypeException();
|
|
||||||
ite.initCause(pae);
|
|
||||||
throw ite;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < fields.length; i++) {
|
|
||||||
Field next = fields[i];
|
|
||||||
Class fieldType = next.getType();
|
|
||||||
if( (fieldType != java.lang.String.class) &&
|
|
||||||
!isPrimitive(fieldType) ) {
|
|
||||||
String msg = "Constant field '" + next.getName() +
|
|
||||||
"' in class '" + next.getDeclaringClass().getName() +
|
|
||||||
"' has invalid type' " + next.getType() + "'. Constants" +
|
|
||||||
" in RMI/IIOP interfaces can only have primitive" +
|
|
||||||
" types and java.lang.String types.";
|
|
||||||
throw new IDLTypeException(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,138 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.iiop;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.protocol.Request;
|
|
||||||
import com.sun.corba.se.impl.core.ClientRequest;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContext;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContexts;
|
|
||||||
import com.sun.corba.se.impl.core.ClientResponse;
|
|
||||||
import com.sun.corba.se.impl.core.ServerRequest;
|
|
||||||
import com.sun.corba.se.impl.core.ServerResponse;
|
|
||||||
import com.sun.corba.se.impl.corba.IOR;
|
|
||||||
import com.sun.corba.se.impl.corba.GIOPVersion;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage;
|
|
||||||
import com.sun.corba.se.impl.orbutil.ORBConstants;
|
|
||||||
import com.sun.corba.se.impl.core.ORBVersion;
|
|
||||||
import com.sun.corba.se.impl.core.ORB;
|
|
||||||
import com.sun.corba.se.impl.orbutil.ORBUtility;
|
|
||||||
import com.sun.corba.se.impl.ior.ObjectKeyFactory ;
|
|
||||||
import com.sun.corba.se.impl.ior.ObjectKey ;
|
|
||||||
import com.sun.corba.se.impl.ior.ObjectKeyTemplate ;
|
|
||||||
import com.sun.corba.se.impl.ior.IIOPProfile;
|
|
||||||
|
|
||||||
public class LocalClientRequestImpl extends IIOPOutputStream
|
|
||||||
implements ClientRequest
|
|
||||||
{
|
|
||||||
public LocalClientRequestImpl( GIOPVersion gv,
|
|
||||||
ORB orb, IOR ior, short addrDisposition,
|
|
||||||
String operationName, boolean oneway, ServiceContexts svc,
|
|
||||||
int requestId, byte streamFormatVersion)
|
|
||||||
{
|
|
||||||
super(gv,
|
|
||||||
orb,
|
|
||||||
null,
|
|
||||||
BufferManagerFactory.newBufferManagerWrite(BufferManagerFactory.GROW),
|
|
||||||
streamFormatVersion);
|
|
||||||
|
|
||||||
this.isOneway = oneway;
|
|
||||||
boolean responseExpected = !isOneway;
|
|
||||||
|
|
||||||
IIOPProfile iop = ior.getProfile();
|
|
||||||
ObjectKey okey = iop.getObjectKey();
|
|
||||||
ObjectKeyTemplate oktemp = okey.getTemplate() ;
|
|
||||||
ORBVersion version = oktemp.getORBVersion() ;
|
|
||||||
orb.setORBVersion( version ) ;
|
|
||||||
|
|
||||||
this.request = MessageBase.createRequest(orb, gv, requestId,
|
|
||||||
responseExpected, ior, addrDisposition, operationName, svc, null);
|
|
||||||
setMessage(request);
|
|
||||||
request.write(this);
|
|
||||||
|
|
||||||
// mark beginning of msg body for possible later use
|
|
||||||
bodyBegin = getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRequestId() {
|
|
||||||
return request.getRequestId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOneWay() {
|
|
||||||
return isOneway;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceContexts getServiceContexts() {
|
|
||||||
return request.getServiceContexts();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOperationName() {
|
|
||||||
return request.getOperation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectKey getObjectKey() {
|
|
||||||
return request.getObjectKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerRequest getServerRequest()
|
|
||||||
{
|
|
||||||
// Set the size of the marshalled data in the message header.
|
|
||||||
getMessage().setSize( getByteBuffer(), getSize() ) ;
|
|
||||||
|
|
||||||
// Construct a new ServerRequest out of the buffer in this ClientRequest
|
|
||||||
LocalServerRequestImpl serverRequest = new LocalServerRequestImpl(
|
|
||||||
(ORB)orb(), toByteArray(), request ) ;
|
|
||||||
|
|
||||||
// Skip over all of the GIOP header information. This positions
|
|
||||||
// the offset in the buffer so that the skeleton can correctly read
|
|
||||||
// the marshalled arguments.
|
|
||||||
serverRequest.setIndex( bodyBegin ) ;
|
|
||||||
|
|
||||||
return serverRequest ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientResponse invoke()
|
|
||||||
{
|
|
||||||
ORB myORB = (ORB)orb() ;
|
|
||||||
|
|
||||||
ServerResponse serverResponse = myORB.process( getServerRequest() ) ;
|
|
||||||
|
|
||||||
LocalServerResponseImpl lsr = (LocalServerResponseImpl)serverResponse ;
|
|
||||||
|
|
||||||
return lsr.getClientResponse() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if the request is local.
|
|
||||||
*/
|
|
||||||
public boolean isLocal(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RequestMessage request;
|
|
||||||
private int bodyBegin;
|
|
||||||
private boolean isOneway;
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.iiop;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.omg.CORBA.SystemException;
|
|
||||||
import org.omg.CORBA.CompletionStatus;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.core.Response;
|
|
||||||
import com.sun.corba.se.impl.core.ClientResponse;
|
|
||||||
import com.sun.corba.se.impl.corba.IOR;
|
|
||||||
import com.sun.corba.se.impl.core.ORB;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContext;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContexts;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
|
|
||||||
import com.sun.corba.se.impl.orbutil.MinorCodes;
|
|
||||||
|
|
||||||
class LocalClientResponseImpl extends IIOPInputStream implements ClientResponse
|
|
||||||
{
|
|
||||||
LocalClientResponseImpl(ORB orb, byte[] buf, ReplyMessage header)
|
|
||||||
{
|
|
||||||
super(orb, buf, header.getSize(), header.isLittleEndian(), header, null);
|
|
||||||
|
|
||||||
this.reply = header;
|
|
||||||
|
|
||||||
// NOTE (Ram J) (06/02/2000) if we set result.setIndex(bodyBegin)
|
|
||||||
// in LocalServerResponse.getClientResponse(), then we do not need
|
|
||||||
// to read the headers (done below) anymore.
|
|
||||||
// This will be an optimisation which is can be done to speed up the
|
|
||||||
// local invocation by avoiding reading the headers in the local cases.
|
|
||||||
|
|
||||||
// BUGFIX(Ram Jeyaraman) This has been moved from
|
|
||||||
// LocalServerResponse.getClientResponse()
|
|
||||||
// Skip over all of the GIOP header information. This positions
|
|
||||||
// the offset in the buffer so that the skeleton can correctly read
|
|
||||||
// the marshalled arguments.
|
|
||||||
this.setIndex(Message.GIOPMessageHeaderLength);
|
|
||||||
|
|
||||||
// BUGFIX(Ram Jeyaraman) For local invocations, the reply mesg fields
|
|
||||||
// needs to be set, by reading the response buffer contents
|
|
||||||
// to correctly set the exception type and other info.
|
|
||||||
this.reply.read(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalClientResponseImpl(SystemException ex)
|
|
||||||
{
|
|
||||||
this.systemException = ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSystemException() {
|
|
||||||
if ( reply != null )
|
|
||||||
return reply.getReplyStatus() == ReplyMessage.SYSTEM_EXCEPTION;
|
|
||||||
else
|
|
||||||
return (systemException != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUserException() {
|
|
||||||
if ( reply != null )
|
|
||||||
return reply.getReplyStatus() == ReplyMessage.USER_EXCEPTION;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLocationForward() {
|
|
||||||
if ( reply != null ) {
|
|
||||||
return ( (reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD) ||
|
|
||||||
(reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD_PERM) );
|
|
||||||
//return reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDifferentAddrDispositionRequested() {
|
|
||||||
if (reply != null) {
|
|
||||||
return reply.getReplyStatus() == ReplyMessage.NEEDS_ADDRESSING_MODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getAddrDisposition() {
|
|
||||||
if (reply != null) {
|
|
||||||
return reply.getAddrDisposition();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new org.omg.CORBA.INTERNAL(
|
|
||||||
"Null reply in getAddrDisposition",
|
|
||||||
MinorCodes.NULL_REPLY_IN_GET_ADDR_DISPOSITION,
|
|
||||||
CompletionStatus.COMPLETED_MAYBE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IOR getForwardedIOR() {
|
|
||||||
if ( reply != null )
|
|
||||||
return reply.getIOR();
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRequestId() {
|
|
||||||
if ( reply != null )
|
|
||||||
return reply.getRequestId();
|
|
||||||
else
|
|
||||||
throw new org.omg.CORBA.INTERNAL("Error in getRequestId");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceContexts getServiceContexts() {
|
|
||||||
if ( reply != null )
|
|
||||||
return reply.getServiceContexts();
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemException getSystemException() {
|
|
||||||
if ( reply != null )
|
|
||||||
return reply.getSystemException();
|
|
||||||
else
|
|
||||||
return systemException;
|
|
||||||
}
|
|
||||||
|
|
||||||
public java.lang.String peekUserExceptionId() {
|
|
||||||
mark(Integer.MAX_VALUE);
|
|
||||||
String result = read_string();
|
|
||||||
reset();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if the response is local.
|
|
||||||
*/
|
|
||||||
public boolean isLocal(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ReplyMessage reply;
|
|
||||||
private SystemException systemException;
|
|
||||||
}
|
|
|
@ -1,208 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.iiop;
|
|
||||||
|
|
||||||
import org.omg.CORBA.SystemException;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.core.ServerRequest;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContext;
|
|
||||||
import com.sun.corba.se.impl.core.DuplicateServiceContext;
|
|
||||||
import com.sun.corba.se.impl.core.UEInfoServiceContext;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContexts;
|
|
||||||
import com.sun.corba.se.impl.core.ServerResponse;
|
|
||||||
import com.sun.corba.se.impl.corba.IOR;
|
|
||||||
import com.sun.corba.se.impl.core.ORB;
|
|
||||||
import com.sun.corba.se.impl.orbutil.ORBUtility; //d11638
|
|
||||||
import org.omg.CORBA.portable.UnknownException;
|
|
||||||
import org.omg.CORBA.UNKNOWN;
|
|
||||||
import org.omg.CORBA.CompletionStatus;
|
|
||||||
import com.sun.corba.se.impl.ior.ObjectKey;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage;
|
|
||||||
|
|
||||||
class LocalServerRequestImpl extends IIOPInputStream implements ServerRequest {
|
|
||||||
org.omg.CORBA.portable.OutputStream replyStream;
|
|
||||||
org.omg.CORBA.portable.OutputStream exceptionReplyStream;
|
|
||||||
|
|
||||||
LocalServerRequestImpl(ORB orb, byte[] buf, RequestMessage header)
|
|
||||||
{
|
|
||||||
super(orb, buf, header.getSize(), header.isLittleEndian(), header, null );
|
|
||||||
|
|
||||||
this.request = header;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRequestId() {
|
|
||||||
return request.getRequestId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOneWay() {
|
|
||||||
return !request.isResponseExpected();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceContexts getServiceContexts() {
|
|
||||||
return request.getServiceContexts();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOperationName() {
|
|
||||||
return request.getOperation();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectKey getObjectKey() {
|
|
||||||
return request.getObjectKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerResponse createResponse(ServiceContexts svc)
|
|
||||||
{
|
|
||||||
return new LocalServerResponseImpl(this, svc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public org.omg.CORBA.portable.OutputStream createReply() {
|
|
||||||
if (replyStream == null) {
|
|
||||||
replyStream = (org.omg.CORBA.portable.OutputStream)
|
|
||||||
createResponse(null);
|
|
||||||
}
|
|
||||||
return replyStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
public org.omg.CORBA.portable.OutputStream createExceptionReply() {
|
|
||||||
if (exceptionReplyStream == null) {
|
|
||||||
exceptionReplyStream = (org.omg.CORBA.portable.OutputStream)
|
|
||||||
createUserExceptionResponse(null);
|
|
||||||
}
|
|
||||||
return exceptionReplyStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerResponse createUserExceptionResponse(
|
|
||||||
ServiceContexts svc)
|
|
||||||
{
|
|
||||||
return new LocalServerResponseImpl(this, svc, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerResponse createUnknownExceptionResponse(
|
|
||||||
UnknownException ex) {
|
|
||||||
ServiceContexts contexts = null;
|
|
||||||
SystemException sys = new UNKNOWN( 0,
|
|
||||||
CompletionStatus.COMPLETED_MAYBE);
|
|
||||||
|
|
||||||
try {
|
|
||||||
contexts = new ServiceContexts( (ORB)orb() );
|
|
||||||
UEInfoServiceContext uei = new UEInfoServiceContext(sys);
|
|
||||||
contexts.put(uei) ;
|
|
||||||
} catch (DuplicateServiceContext d) {
|
|
||||||
// can't happen
|
|
||||||
}
|
|
||||||
|
|
||||||
return createSystemExceptionResponse(sys,contexts);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerResponse createSystemExceptionResponse(
|
|
||||||
SystemException ex, ServiceContexts svc) {
|
|
||||||
|
|
||||||
// Only do this if interceptors have been initialized on this request
|
|
||||||
// and have not completed their lifecycle (otherwise the info stack
|
|
||||||
// may be empty or have a different request's entry on top).
|
|
||||||
if (executePIInResponseConstructor()) {
|
|
||||||
// Inform Portable Interceptors of the SystemException. This is
|
|
||||||
// required to be done here because the ending interception point
|
|
||||||
// is called in the ServerResponseImpl constructor called below
|
|
||||||
// but we do not currently write the SystemException into the
|
|
||||||
// response until after the ending point is called.
|
|
||||||
ORB orb = (ORB)orb();
|
|
||||||
orb.getPIHandler().setServerPIInfo( ex );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orb() != null && ((ORB)orb()).subcontractDebugFlag && ex != null)
|
|
||||||
ORBUtility.dprint(this, "Sending SystemException:", ex);
|
|
||||||
|
|
||||||
LocalServerResponseImpl response =
|
|
||||||
new LocalServerResponseImpl(this, svc, false);
|
|
||||||
ORBUtility.writeSystemException(ex, response);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerResponse createLocationForward(
|
|
||||||
IOR ior, ServiceContexts svc) {
|
|
||||||
ReplyMessage reply = MessageBase.createReply( (ORB)orb(),
|
|
||||||
request.getGIOPVersion(), request.getRequestId(),
|
|
||||||
ReplyMessage.LOCATION_FORWARD, svc, ior);
|
|
||||||
LocalServerResponseImpl response =
|
|
||||||
new LocalServerResponseImpl(this, reply, ior);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RequestMessage request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if the request is local.
|
|
||||||
*/
|
|
||||||
public boolean isLocal(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean _executeReturnServantInResponseConstructor = false;
|
|
||||||
|
|
||||||
public boolean executeReturnServantInResponseConstructor()
|
|
||||||
{
|
|
||||||
return _executeReturnServantInResponseConstructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExecuteReturnServantInResponseConstructor(boolean b)
|
|
||||||
{
|
|
||||||
_executeReturnServantInResponseConstructor = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean _executeRemoveThreadInfoInResponseConstructor = false;
|
|
||||||
|
|
||||||
public boolean executeRemoveThreadInfoInResponseConstructor()
|
|
||||||
{
|
|
||||||
return _executeRemoveThreadInfoInResponseConstructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExecuteRemoveThreadInfoInResponseConstructor(boolean b)
|
|
||||||
{
|
|
||||||
_executeRemoveThreadInfoInResponseConstructor = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean _executePIInResponseConstructor = false;
|
|
||||||
|
|
||||||
public boolean executePIInResponseConstructor() {
|
|
||||||
return _executePIInResponseConstructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExecutePIInResponseConstructor( boolean b ) {
|
|
||||||
_executePIInResponseConstructor = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We know that we're talking to the same ValueHandler, so
|
|
||||||
// use the maximum version it supports.
|
|
||||||
public byte getStreamFormatVersionForReply() {
|
|
||||||
return ORBUtility.getMaxStreamFormatVersion();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,192 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.iiop;
|
|
||||||
|
|
||||||
import org.omg.CORBA.SystemException;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.core.ServerResponse;
|
|
||||||
import com.sun.corba.se.impl.core.ORB;
|
|
||||||
import com.sun.corba.se.impl.corba.IOR;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContext;
|
|
||||||
import com.sun.corba.se.impl.core.ServiceContexts;
|
|
||||||
import com.sun.corba.se.impl.core.ClientResponse;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
|
|
||||||
|
|
||||||
class LocalServerResponseImpl
|
|
||||||
extends IIOPOutputStream
|
|
||||||
implements ServerResponse
|
|
||||||
{
|
|
||||||
LocalServerResponseImpl(LocalServerRequestImpl request, ServiceContexts svc)
|
|
||||||
{
|
|
||||||
this(request,
|
|
||||||
MessageBase.createReply(
|
|
||||||
(ORB)request.orb(),
|
|
||||||
request.getGIOPVersion(),
|
|
||||||
request.getRequestId(), ReplyMessage.NO_EXCEPTION,
|
|
||||||
svc, null),
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalServerResponseImpl(LocalServerRequestImpl request, ServiceContexts svc,
|
|
||||||
boolean user)
|
|
||||||
{
|
|
||||||
this(request,
|
|
||||||
MessageBase.createReply(
|
|
||||||
(ORB)request.orb(),
|
|
||||||
request.getGIOPVersion(), request.getRequestId(),
|
|
||||||
user ? ReplyMessage.USER_EXCEPTION :
|
|
||||||
ReplyMessage.SYSTEM_EXCEPTION,
|
|
||||||
svc, null),
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalServerResponseImpl( LocalServerRequestImpl request, ReplyMessage reply,
|
|
||||||
IOR ior)
|
|
||||||
{
|
|
||||||
super(request.getGIOPVersion(),
|
|
||||||
(ORB)request.orb(),
|
|
||||||
null,
|
|
||||||
BufferManagerFactory.newBufferManagerWrite(BufferManagerFactory.GROW),
|
|
||||||
request.getStreamFormatVersionForReply());
|
|
||||||
|
|
||||||
setMessage(reply);
|
|
||||||
|
|
||||||
ORB orb = (ORB)request.orb();
|
|
||||||
|
|
||||||
ServerResponseImpl.runServantPostInvoke(orb, request);
|
|
||||||
|
|
||||||
if( request.executePIInResponseConstructor() ) {
|
|
||||||
// Invoke server request ending interception points (send_*):
|
|
||||||
// Note: this may end up with a SystemException or an internal
|
|
||||||
// Runtime ForwardRequest.
|
|
||||||
orb.getPIHandler().invokeServerPIEndingPoint( reply );
|
|
||||||
|
|
||||||
// Note this will be executed even if a ForwardRequest or
|
|
||||||
// SystemException is thrown by a Portable Interceptors ending
|
|
||||||
// point since we end up in this constructor again anyway.
|
|
||||||
orb.getPIHandler().cleanupServerPIRequest();
|
|
||||||
|
|
||||||
// See (Local)ServerRequestImpl.createSystemExceptionResponse
|
|
||||||
// for why this is necesary.
|
|
||||||
request.setExecutePIInResponseConstructor(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once you get here then the final reply is available (i.e.,
|
|
||||||
// postinvoke and interceptors have completed.
|
|
||||||
if (request.executeRemoveThreadInfoInResponseConstructor()) {
|
|
||||||
ServerResponseImpl.removeThreadInfo(orb, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
reply.write(this);
|
|
||||||
if (reply.getIOR() != null)
|
|
||||||
reply.getIOR().write(this);
|
|
||||||
|
|
||||||
this.reply = reply;
|
|
||||||
this.ior = reply.getIOR();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSystemException() {
|
|
||||||
if (reply != null)
|
|
||||||
return reply.getReplyStatus() == ReplyMessage.SYSTEM_EXCEPTION;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUserException() {
|
|
||||||
if (reply != null)
|
|
||||||
return reply.getReplyStatus() == ReplyMessage.USER_EXCEPTION;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLocationForward() {
|
|
||||||
if (ior != null)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IOR getForwardedIOR() {
|
|
||||||
return ior;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRequestId() {
|
|
||||||
if (reply != null)
|
|
||||||
return reply.getRequestId();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceContexts getServiceContexts() {
|
|
||||||
if (reply != null)
|
|
||||||
return reply.getServiceContexts();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SystemException getSystemException() {
|
|
||||||
if (reply != null)
|
|
||||||
return reply.getSystemException();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplyMessage getReply()
|
|
||||||
{
|
|
||||||
return reply ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientResponse getClientResponse()
|
|
||||||
{
|
|
||||||
// set the size of the marshalled data in the message header
|
|
||||||
getMessage().setSize(getByteBuffer(), getSize());
|
|
||||||
|
|
||||||
// Construct a new ClientResponse out of the buffer in this ClientRequest
|
|
||||||
LocalClientResponseImpl result =
|
|
||||||
new LocalClientResponseImpl( (ORB)orb(), toByteArray(), reply);
|
|
||||||
|
|
||||||
// NOTE (Ram J) (06/02/2000) if we set result.setIndex(bodyBegin) here
|
|
||||||
// then the LocalClientResponse does not need to read the headers anymore.
|
|
||||||
// This will be an optimisation which is can be done to speed up the
|
|
||||||
// local invocation by avoiding reading the headers in the local cases.
|
|
||||||
|
|
||||||
// BUGFIX(Ram Jeyaraman) result.setOffset is now done in
|
|
||||||
// LocalClientResponseImpl constructor.
|
|
||||||
/*
|
|
||||||
// Skip over all of the GIOP header information. This positions
|
|
||||||
// the offset in the buffer so that the skeleton can correctly read
|
|
||||||
// the marshalled arguments.
|
|
||||||
result.setOffset( bodyBegin ) ;
|
|
||||||
*/
|
|
||||||
|
|
||||||
return result ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if the response is local.
|
|
||||||
*/
|
|
||||||
public boolean isLocal(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ReplyMessage reply;
|
|
||||||
private IOR ior; // forwarded IOR
|
|
||||||
}
|
|
|
@ -1,710 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2004, Oracle and/or its affiliates. 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.corba.se.impl.transport;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.channels.SelectableChannel;
|
|
||||||
import java.nio.channels.SelectionKey;
|
|
||||||
import java.nio.channels.SocketChannel;
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.omg.CORBA.COMM_FAILURE;
|
|
||||||
import org.omg.CORBA.CompletionStatus;
|
|
||||||
import org.omg.CORBA.DATA_CONVERSION;
|
|
||||||
import org.omg.CORBA.INTERNAL;
|
|
||||||
import org.omg.CORBA.MARSHAL;
|
|
||||||
import org.omg.CORBA.OBJECT_NOT_EXIST;
|
|
||||||
import org.omg.CORBA.SystemException;
|
|
||||||
|
|
||||||
import com.sun.org.omg.SendingContext.CodeBase;
|
|
||||||
|
|
||||||
import com.sun.corba.se.pept.broker.Broker;
|
|
||||||
import com.sun.corba.se.pept.encoding.InputObject;
|
|
||||||
import com.sun.corba.se.pept.encoding.OutputObject;
|
|
||||||
import com.sun.corba.se.pept.protocol.MessageMediator;
|
|
||||||
import com.sun.corba.se.pept.transport.Acceptor;
|
|
||||||
import com.sun.corba.se.pept.transport.Connection;
|
|
||||||
import com.sun.corba.se.pept.transport.ConnectionCache;
|
|
||||||
import com.sun.corba.se.pept.transport.ContactInfo;
|
|
||||||
import com.sun.corba.se.pept.transport.EventHandler;
|
|
||||||
import com.sun.corba.se.pept.transport.InboundConnectionCache;
|
|
||||||
import com.sun.corba.se.pept.transport.OutboundConnectionCache;
|
|
||||||
import com.sun.corba.se.pept.transport.ResponseWaitingRoom;
|
|
||||||
import com.sun.corba.se.pept.transport.Selector;
|
|
||||||
|
|
||||||
import com.sun.corba.se.spi.ior.IOR;
|
|
||||||
import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
|
|
||||||
import com.sun.corba.se.spi.logging.CORBALogDomains;
|
|
||||||
import com.sun.corba.se.spi.orb.ORB ;
|
|
||||||
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
||||||
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
|
|
||||||
import com.sun.corba.se.spi.transport.CorbaContactInfo;
|
|
||||||
import com.sun.corba.se.spi.transport.CorbaConnection;
|
|
||||||
import com.sun.corba.se.spi.transport.CorbaResponseWaitingRoom;
|
|
||||||
|
|
||||||
import com.sun.corba.se.impl.encoding.CachedCodeBase;
|
|
||||||
import com.sun.corba.se.impl.encoding.CDRInputStream_1_0;
|
|
||||||
import com.sun.corba.se.impl.encoding.CDROutputObject;
|
|
||||||
import com.sun.corba.se.impl.encoding.CDROutputStream_1_0;
|
|
||||||
import com.sun.corba.se.impl.encoding.CodeSetComponentInfo;
|
|
||||||
import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry;
|
|
||||||
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
|
|
||||||
import com.sun.corba.se.impl.orbutil.ORBConstants;
|
|
||||||
import com.sun.corba.se.impl.orbutil.ORBUtility;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
|
|
||||||
import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase;
|
|
||||||
import com.sun.corba.se.impl.transport.CorbaResponseWaitingRoomImpl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Ken Cavanaugh
|
|
||||||
*/
|
|
||||||
public class BufferConnectionImpl
|
|
||||||
extends
|
|
||||||
EventHandlerBase
|
|
||||||
implements
|
|
||||||
CorbaConnection,
|
|
||||||
Work
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// New transport.
|
|
||||||
//
|
|
||||||
|
|
||||||
protected long enqueueTime;
|
|
||||||
|
|
||||||
public SocketChannel getSocketChannel()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// REVISIT:
|
|
||||||
// protected for test: genericRPCMSGFramework.IIOPConnection constructor.
|
|
||||||
|
|
||||||
//
|
|
||||||
// From iiop.Connection.java
|
|
||||||
//
|
|
||||||
|
|
||||||
protected long timeStamp = 0;
|
|
||||||
protected boolean isServer = false;
|
|
||||||
|
|
||||||
// Start at some value other than zero since this is a magic
|
|
||||||
// value in some protocols.
|
|
||||||
protected int requestId = 5;
|
|
||||||
protected CorbaResponseWaitingRoom responseWaitingRoom;
|
|
||||||
protected int state;
|
|
||||||
protected java.lang.Object stateEvent = new java.lang.Object();
|
|
||||||
protected java.lang.Object writeEvent = new java.lang.Object();
|
|
||||||
protected boolean writeLocked;
|
|
||||||
protected int serverRequestCount = 0;
|
|
||||||
|
|
||||||
// Server request map: used on the server side of Connection
|
|
||||||
// Maps request ID to IIOPInputStream.
|
|
||||||
Map serverRequestMap = new HashMap() ;
|
|
||||||
|
|
||||||
// This is a flag associated per connection telling us if the
|
|
||||||
// initial set of sending contexts were sent to the receiver
|
|
||||||
// already...
|
|
||||||
protected boolean postInitialContexts = false;
|
|
||||||
|
|
||||||
// Remote reference to CodeBase server (supplies
|
|
||||||
// FullValueDescription, among other things)
|
|
||||||
protected IOR codeBaseServerIOR;
|
|
||||||
|
|
||||||
// CodeBase cache for this connection. This will cache remote operations,
|
|
||||||
// handle connecting, and ensure we don't do any remote operations until
|
|
||||||
// necessary.
|
|
||||||
protected CachedCodeBase cachedCodeBase = new CachedCodeBase(this);
|
|
||||||
|
|
||||||
protected ORBUtilSystemException wrapper ;
|
|
||||||
|
|
||||||
List buffers ;
|
|
||||||
|
|
||||||
public BufferConnectionImpl(ORB orb, byte[][] data )
|
|
||||||
{
|
|
||||||
this.orb = orb;
|
|
||||||
wrapper = ORBUtilSystemException.get( orb,
|
|
||||||
CORBALogDomains.RPC_TRANSPORT ) ;
|
|
||||||
buffers = new ArrayList() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// framework.transport.Connection
|
|
||||||
//
|
|
||||||
|
|
||||||
public boolean shouldRegisterReadEvent()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldRegisterServerReadEvent()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean read()
|
|
||||||
{
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CorbaMessageMediator readBits()
|
|
||||||
{
|
|
||||||
return null ;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean dispatch(CorbaMessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldUseDirectByteBuffers()
|
|
||||||
{
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only called from readGIOPMessage with (12, 0, 12) as arguments
|
|
||||||
// size is size of buffer to create
|
|
||||||
// offset is offset from start of message in buffer
|
|
||||||
// length is length to read
|
|
||||||
public ByteBuffer read(int size, int offset, int length)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
byte[] buf = new byte[size];
|
|
||||||
readFully( buf, offset, length);
|
|
||||||
ByteBuffer byteBuffer = ByteBuffer.wrap(buf);
|
|
||||||
byteBuffer.limit(size);
|
|
||||||
return byteBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only called as read( buf, 12, msgsize-12 ) in readGIOPMessage
|
|
||||||
// We can ignore the byteBuffer parameter
|
|
||||||
// offset is the starting position to place data in the result
|
|
||||||
// length is the length of the data to read
|
|
||||||
public ByteBuffer read(ByteBuffer byteBuffer, int offset, int length)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
int size = offset + length;
|
|
||||||
byte[] buf = new byte[size];
|
|
||||||
readFully(buf, offset, length);
|
|
||||||
return ByteBuffer.wrap(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read size bytes from buffer list and place the data
|
|
||||||
// starting at offset in buf.
|
|
||||||
public void readFully(byte[] buf, int offset, int size)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
int remaining = size ;
|
|
||||||
int position = offset ;
|
|
||||||
while (remaining > 0) {
|
|
||||||
ByteBuffer buff = (ByteBuffer)buffers.get(0) ;
|
|
||||||
int dataSize = buff.remaining() ;
|
|
||||||
int xferSize = dataSize ;
|
|
||||||
if (dataSize >= remaining) :
|
|
||||||
xferSize = remaining ;
|
|
||||||
buffers.remove(0) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
buff.get( buf, offset, xferSize ) ;
|
|
||||||
|
|
||||||
offset += xferSize ;
|
|
||||||
remaining -= xferSize ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(ByteBuffer byteBuffer)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
buffers.add( byteBuffer ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note:it is possible for this to be called more than once
|
|
||||||
*/
|
|
||||||
public synchronized void close()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Acceptor getAcceptor()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactInfo getContactInfo()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventHandler getEventHandler()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OutputObject createOutputObject(MessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
// REVISIT - remove this method from Connection and all it subclasses.
|
|
||||||
throw new RuntimeException("*****SocketOrChannelConnectionImpl.createOutputObject - should not be called.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is used by the GIOPOutputObject in order to
|
|
||||||
// throw the correct error when handling code sets.
|
|
||||||
// Can we determine if we are on the server side by
|
|
||||||
// other means? XREVISIT
|
|
||||||
public boolean isServer()
|
|
||||||
{
|
|
||||||
return isServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBusy()
|
|
||||||
{
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeStamp()
|
|
||||||
{
|
|
||||||
return timeStamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeStamp(long time)
|
|
||||||
{
|
|
||||||
timeStamp = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(String stateString)
|
|
||||||
{
|
|
||||||
synchronized (stateEvent) {
|
|
||||||
if (stateString.equals("ESTABLISHED")) {
|
|
||||||
state = ESTABLISHED;
|
|
||||||
stateEvent.notifyAll();
|
|
||||||
} else {
|
|
||||||
// REVISIT: ASSERT
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeLock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeUnlock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendWithoutLock(OutputObject outputObject)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerWaiter(MessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregisterWaiter(MessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputObject waitForResponse(MessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
return null ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConnectionCache(ConnectionCache connectionCache)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConnectionCache getConnectionCache()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// EventHandler methods
|
|
||||||
//
|
|
||||||
|
|
||||||
public SelectableChannel getChannel()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInterestOps()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Acceptor getAcceptor() - already defined above.
|
|
||||||
|
|
||||||
public Connection getConnection()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Work methods.
|
|
||||||
//
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doWork()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnqueueTime(long timeInMillis)
|
|
||||||
{
|
|
||||||
enqueueTime = timeInMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getEnqueueTime()
|
|
||||||
{
|
|
||||||
return enqueueTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// spi.transport.CorbaConnection.
|
|
||||||
//
|
|
||||||
|
|
||||||
public ResponseWaitingRoom getResponseWaitingRoom()
|
|
||||||
{
|
|
||||||
return null ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// REVISIT - inteface defines isServer but already defined in
|
|
||||||
// higher interface.
|
|
||||||
|
|
||||||
|
|
||||||
public void serverRequestMapPut(int requestId,
|
|
||||||
CorbaMessageMediator messageMediator)
|
|
||||||
{
|
|
||||||
serverRequestMap.put(new Integer(requestId), messageMediator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CorbaMessageMediator serverRequestMapGet(int requestId)
|
|
||||||
{
|
|
||||||
return (CorbaMessageMediator)
|
|
||||||
serverRequestMap.get(new Integer(requestId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serverRequestMapRemove(int requestId)
|
|
||||||
{
|
|
||||||
serverRequestMap.remove(new Integer(requestId));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// REVISIT: this is also defined in:
|
|
||||||
// com.sun.corba.se.spi.legacy.connection.Connection
|
|
||||||
public java.net.Socket getSocket()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** It is possible for a Close Connection to have been
|
|
||||||
** sent here, but we will not check for this. A "lazy"
|
|
||||||
** Exception will be thrown in the Worker thread after the
|
|
||||||
** incoming request has been processed even though the connection
|
|
||||||
** is closed before the request is processed. This is o.k because
|
|
||||||
** it is a boundary condition. To prevent it we would have to add
|
|
||||||
** more locks which would reduce performance in the normal case.
|
|
||||||
**/
|
|
||||||
public synchronized void serverRequestProcessingBegins()
|
|
||||||
{
|
|
||||||
serverRequestCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void serverRequestProcessingEnds()
|
|
||||||
{
|
|
||||||
serverRequestCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
public synchronized int getNextRequestId()
|
|
||||||
{
|
|
||||||
return requestId++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Negotiated code sets for char and wchar data
|
|
||||||
protected CodeSetComponentInfo.CodeSetContext codeSetContext = null;
|
|
||||||
|
|
||||||
public ORB getBroker()
|
|
||||||
{
|
|
||||||
return orb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CodeSetComponentInfo.CodeSetContext getCodeSetContext()
|
|
||||||
{
|
|
||||||
// Needs to be synchronized for the following case when the client
|
|
||||||
// doesn't send the code set context twice, and we have two threads
|
|
||||||
// in ServerRequestDispatcher processCodeSetContext.
|
|
||||||
//
|
|
||||||
// Thread A checks to see if there is a context, there is none, so
|
|
||||||
// it calls setCodeSetContext, getting the synch lock.
|
|
||||||
// Thread B checks to see if there is a context. If we didn't synch,
|
|
||||||
// it might decide to outlaw wchar/wstring.
|
|
||||||
if (codeSetContext == null) {
|
|
||||||
synchronized(this) {
|
|
||||||
return codeSetContext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return codeSetContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void setCodeSetContext(CodeSetComponentInfo.CodeSetContext csc) {
|
|
||||||
// Double check whether or not we need to do this
|
|
||||||
if (codeSetContext == null) {
|
|
||||||
|
|
||||||
if (OSFCodeSetRegistry.lookupEntry(csc.getCharCodeSet()) == null ||
|
|
||||||
OSFCodeSetRegistry.lookupEntry(csc.getWCharCodeSet()) == null) {
|
|
||||||
// If the client says it's negotiated a code set that
|
|
||||||
// isn't a fallback and we never said we support, then
|
|
||||||
// it has a bug.
|
|
||||||
throw wrapper.badCodesetsFromClient() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
codeSetContext = csc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// from iiop.IIOPConnection.java
|
|
||||||
//
|
|
||||||
|
|
||||||
// Map request ID to an InputObject.
|
|
||||||
// This is so the client thread can start unmarshaling
|
|
||||||
// the reply and remove it from the out_calls map while the
|
|
||||||
// ReaderThread can still obtain the input stream to give
|
|
||||||
// new fragments. Only the ReaderThread touches the clientReplyMap,
|
|
||||||
// so it doesn't incur synchronization overhead.
|
|
||||||
|
|
||||||
public MessageMediator clientRequestMapGet(int requestId)
|
|
||||||
{
|
|
||||||
return null ;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MessageMediator clientReply_1_1;
|
|
||||||
|
|
||||||
public void clientReply_1_1_Put(MessageMediator x)
|
|
||||||
{
|
|
||||||
clientReply_1_1 = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageMediator clientReply_1_1_Get()
|
|
||||||
{
|
|
||||||
return clientReply_1_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clientReply_1_1_Remove()
|
|
||||||
{
|
|
||||||
clientReply_1_1 = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MessageMediator serverRequest_1_1;
|
|
||||||
|
|
||||||
public void serverRequest_1_1_Put(MessageMediator x)
|
|
||||||
{
|
|
||||||
serverRequest_1_1 = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageMediator serverRequest_1_1_Get()
|
|
||||||
{
|
|
||||||
return serverRequest_1_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serverRequest_1_1_Remove()
|
|
||||||
{
|
|
||||||
serverRequest_1_1 = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getStateString( int state )
|
|
||||||
{
|
|
||||||
synchronized ( stateEvent ){
|
|
||||||
switch (state) {
|
|
||||||
case OPENING : return "OPENING" ;
|
|
||||||
case ESTABLISHED : return "ESTABLISHED" ;
|
|
||||||
case CLOSE_SENT : return "CLOSE_SENT" ;
|
|
||||||
case CLOSE_RECVD : return "CLOSE_RECVD" ;
|
|
||||||
case ABORT : return "ABORT" ;
|
|
||||||
default : return "???" ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isPostInitialContexts() {
|
|
||||||
return postInitialContexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can never be unset...
|
|
||||||
public synchronized void setPostInitialContexts(){
|
|
||||||
postInitialContexts = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wake up the outstanding requests on the connection, and hand them
|
|
||||||
* COMM_FAILURE exception with a given minor code.
|
|
||||||
*
|
|
||||||
* Also, delete connection from connection table and
|
|
||||||
* stop the reader thread.
|
|
||||||
|
|
||||||
* Note that this should only ever be called by the Reader thread for
|
|
||||||
* this connection.
|
|
||||||
*
|
|
||||||
* @param minor_code The minor code for the COMM_FAILURE major code.
|
|
||||||
* @param die Kill the reader thread (this thread) before exiting.
|
|
||||||
*/
|
|
||||||
public void purgeCalls(SystemException systemException,
|
|
||||||
boolean die, boolean lockHeld)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* The following methods are for dealing with Connection cleaning for
|
|
||||||
* better scalability of servers in high network load conditions.
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
public void sendCloseConnection(GIOPVersion giopVersion)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
Message msg = MessageBase.createCloseConnection(giopVersion);
|
|
||||||
sendHelper(giopVersion, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessageError(GIOPVersion giopVersion)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
Message msg = MessageBase.createMessageError(giopVersion);
|
|
||||||
sendHelper(giopVersion, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a CancelRequest message. This does not lock the connection, so the
|
|
||||||
* caller needs to ensure this method is called appropriately.
|
|
||||||
* @exception IOException - could be due to abortive connection closure.
|
|
||||||
*/
|
|
||||||
public void sendCancelRequest(GIOPVersion giopVersion, int requestId)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
|
|
||||||
Message msg = MessageBase.createCancelRequest(giopVersion, requestId);
|
|
||||||
sendHelper(giopVersion, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void sendHelper(GIOPVersion giopVersion, Message msg)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
// REVISIT: See comments in CDROutputObject constructor.
|
|
||||||
CDROutputObject outputObject =
|
|
||||||
new CDROutputObject((ORB)orb, null, giopVersion, this, msg,
|
|
||||||
ORBConstants.STREAM_FORMAT_VERSION_1);
|
|
||||||
msg.write(outputObject);
|
|
||||||
|
|
||||||
outputObject.writeTo(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendCancelRequestWithLock(GIOPVersion giopVersion,
|
|
||||||
int requestId)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
writeLock();
|
|
||||||
try {
|
|
||||||
sendCancelRequest(giopVersion, requestId);
|
|
||||||
} finally {
|
|
||||||
writeUnlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Begin Code Base methods ---------------------------------------
|
|
||||||
//
|
|
||||||
// Set this connection's code base IOR. The IOR comes from the
|
|
||||||
// SendingContext. This is an optional service context, but all
|
|
||||||
// JavaSoft ORBs send it.
|
|
||||||
//
|
|
||||||
// The set and get methods don't need to be synchronized since the
|
|
||||||
// first possible get would occur during reading a valuetype, and
|
|
||||||
// that would be after the set.
|
|
||||||
|
|
||||||
// Sets this connection's code base IOR. This is done after
|
|
||||||
// getting the IOR out of the SendingContext service context.
|
|
||||||
// Our ORBs always send this, but it's optional in CORBA.
|
|
||||||
|
|
||||||
public final void setCodeBaseIOR(IOR ior) {
|
|
||||||
codeBaseServerIOR = ior;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final IOR getCodeBaseIOR() {
|
|
||||||
return codeBaseServerIOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a CodeBase stub to use in unmarshaling. The CachedCodeBase
|
|
||||||
// won't connect to the remote codebase unless it's necessary.
|
|
||||||
public final CodeBase getCodeBase() {
|
|
||||||
return cachedCodeBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
// End Code Base methods -----------------------------------------
|
|
||||||
|
|
||||||
// Can be overridden in subclass for different options.
|
|
||||||
protected void setSocketOptions(Socket socket)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
synchronized ( stateEvent ){
|
|
||||||
return
|
|
||||||
"BufferConnectionImpl[" + " "
|
|
||||||
+ getStateString( state ) + " "
|
|
||||||
+ shouldUseSelectThreadToWait() + " "
|
|
||||||
+ shouldUseWorkerThreadForEvent()
|
|
||||||
+ "]" ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Must be public - used in encoding.
|
|
||||||
public void dprint(String msg)
|
|
||||||
{
|
|
||||||
ORBUtility.dprint("SocketOrChannelConnectionImpl", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void dprint(String msg, Throwable t)
|
|
||||||
{
|
|
||||||
dprint(msg);
|
|
||||||
t.printStackTrace(System.out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of file.
|
|
|
@ -364,3 +364,7 @@ c9dd82da51ed34a28f7c6b3245163ee962e94572 hs25-b40
|
||||||
5787fac72e760c6a5fd9efa113b0c75caf554136 jdk8-b100
|
5787fac72e760c6a5fd9efa113b0c75caf554136 jdk8-b100
|
||||||
46487ba40ff225654d0c51787ed3839bafcbd9f3 hs25-b43
|
46487ba40ff225654d0c51787ed3839bafcbd9f3 hs25-b43
|
||||||
f6921c876db192bba389cec062855a66372da01c jdk8-b101
|
f6921c876db192bba389cec062855a66372da01c jdk8-b101
|
||||||
|
530fe88b3b2c710f42810b3580d86a0d83ad6c1c hs25-b44
|
||||||
|
c4697c1c448416108743b59118b4a2498b339d0c jdk8-b102
|
||||||
|
7f55137d6aa81efc6eb0035813709f2cb6a26b8b hs25-b45
|
||||||
|
6f9be7f87b9653e94fd8fb3070891a0cc91b15bf jdk8-b103
|
||||||
|
|
|
@ -29,11 +29,10 @@ public interface JVMTIThreadState {
|
||||||
public static final int JVMTI_THREAD_STATE_ALIVE = 0x0001;
|
public static final int JVMTI_THREAD_STATE_ALIVE = 0x0001;
|
||||||
public static final int JVMTI_THREAD_STATE_TERMINATED = 0x0002;
|
public static final int JVMTI_THREAD_STATE_TERMINATED = 0x0002;
|
||||||
public static final int JVMTI_THREAD_STATE_RUNNABLE = 0x0004;
|
public static final int JVMTI_THREAD_STATE_RUNNABLE = 0x0004;
|
||||||
public static final int JVMTI_THREAD_STATE_WAITING = 0x0008;
|
public static final int JVMTI_THREAD_STATE_WAITING = 0x0080;
|
||||||
public static final int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
|
public static final int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
|
||||||
public static final int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
|
public static final int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
|
||||||
public static final int JVMTI_THREAD_STATE_SLEEPING = 0x0040;
|
public static final int JVMTI_THREAD_STATE_SLEEPING = 0x0040;
|
||||||
public static final int JVMTI_THREAD_STATE_WAITING_FOR_NOTIFICATION = 0x0080;
|
|
||||||
public static final int JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100;
|
public static final int JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100;
|
||||||
public static final int JVMTI_THREAD_STATE_PARKED = 0x0200;
|
public static final int JVMTI_THREAD_STATE_PARKED = 0x0200;
|
||||||
public static final int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400;
|
public static final int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400;
|
||||||
|
|
|
@ -32,7 +32,7 @@ import sun.jvm.hotspot.types.*;
|
||||||
// to the sys_thread_t structure of the classic JVM implementation.
|
// to the sys_thread_t structure of the classic JVM implementation.
|
||||||
public class OSThread extends VMObject {
|
public class OSThread extends VMObject {
|
||||||
private static JIntField interruptedField;
|
private static JIntField interruptedField;
|
||||||
private static JIntField threadIdField;
|
private static Field threadIdField;
|
||||||
static {
|
static {
|
||||||
VM.registerVMInitializedObserver(new Observer() {
|
VM.registerVMInitializedObserver(new Observer() {
|
||||||
public void update(Observable o, Object data) {
|
public void update(Observable o, Object data) {
|
||||||
|
@ -44,7 +44,7 @@ public class OSThread extends VMObject {
|
||||||
private static synchronized void initialize(TypeDataBase db) {
|
private static synchronized void initialize(TypeDataBase db) {
|
||||||
Type type = db.lookupType("OSThread");
|
Type type = db.lookupType("OSThread");
|
||||||
interruptedField = type.getJIntField("_interrupted");
|
interruptedField = type.getJIntField("_interrupted");
|
||||||
threadIdField = type.getJIntField("_thread_id");
|
threadIdField = type.getField("_thread_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSThread(Address addr) {
|
public OSThread(Address addr) {
|
||||||
|
@ -56,7 +56,7 @@ public class OSThread extends VMObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int threadId() {
|
public int threadId() {
|
||||||
return (int)threadIdField.getValue(addr);
|
return threadIdField.getJInt(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -74,23 +74,24 @@ public class ClassDump extends Tool {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Ready to go with the database...
|
// Ready to go with the database...
|
||||||
try {
|
try {
|
||||||
// The name of the filter always comes from a System property.
|
if (classFilter == null) {
|
||||||
// If we have a pkgList, pass it, otherwise let the filter read
|
// If not already set, the name of the filter comes from a System property.
|
||||||
// its own System property for the list of classes.
|
// If we have a pkgList, pass it, otherwise let the filter read
|
||||||
String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter",
|
// its own System property for the list of classes.
|
||||||
"sun.jvm.hotspot.tools.jcore.PackageNameFilter");
|
String filterClassName = System.getProperty("sun.jvm.hotspot.tools.jcore.filter",
|
||||||
try {
|
"sun.jvm.hotspot.tools.jcore.PackageNameFilter");
|
||||||
Class filterClass = Class.forName(filterClassName);
|
try {
|
||||||
if (pkgList == null) {
|
Class filterClass = Class.forName(filterClassName);
|
||||||
classFilter = (ClassFilter) filterClass.newInstance();
|
if (pkgList == null) {
|
||||||
} else {
|
classFilter = (ClassFilter) filterClass.newInstance();
|
||||||
Constructor con = filterClass.getConstructor(String.class);
|
} else {
|
||||||
classFilter = (ClassFilter) con.newInstance(pkgList);
|
Constructor con = filterClass.getConstructor(String.class);
|
||||||
|
classFilter = (ClassFilter) con.newInstance(pkgList);
|
||||||
|
}
|
||||||
|
} catch(Exception exp) {
|
||||||
|
System.err.println("Warning: Can not create class filter!");
|
||||||
}
|
}
|
||||||
} catch(Exception exp) {
|
|
||||||
System.err.println("Warning: Can not create class filter!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String outputDirectory = System.getProperty("sun.jvm.hotspot.tools.jcore.outputDir", ".");
|
String outputDirectory = System.getProperty("sun.jvm.hotspot.tools.jcore.outputDir", ".");
|
||||||
setOutputDirectory(outputDirectory);
|
setOutputDirectory(outputDirectory);
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,20 @@
|
||||||
|
|
||||||
TYPE=MINIMAL1
|
TYPE=MINIMAL1
|
||||||
|
|
||||||
INCLUDE_JVMTI ?= false
|
# Force all variables to false, overriding any other
|
||||||
INCLUDE_FPROF ?= false
|
# setting that may have occurred in the makefiles. These
|
||||||
INCLUDE_VM_STRUCTS ?= false
|
# can still be overridden by passing the variable as an
|
||||||
INCLUDE_JNI_CHECK ?= false
|
# argument to 'make'
|
||||||
INCLUDE_SERVICES ?= false
|
INCLUDE_JVMTI := false
|
||||||
INCLUDE_MANAGEMENT ?= false
|
INCLUDE_FPROF := false
|
||||||
INCLUDE_ALL_GCS ?= false
|
INCLUDE_VM_STRUCTS := false
|
||||||
INCLUDE_NMT ?= false
|
INCLUDE_JNI_CHECK := false
|
||||||
INCLUDE_TRACE ?= false
|
INCLUDE_SERVICES := false
|
||||||
INCLUDE_CDS ?= false
|
INCLUDE_MANAGEMENT := false
|
||||||
|
INCLUDE_ALL_GCS := false
|
||||||
|
INCLUDE_NMT := false
|
||||||
|
INCLUDE_TRACE := false
|
||||||
|
INCLUDE_CDS := false
|
||||||
|
|
||||||
CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
||||||
CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
||||||
|
|
|
@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013
|
||||||
|
|
||||||
HS_MAJOR_VER=25
|
HS_MAJOR_VER=25
|
||||||
HS_MINOR_VER=0
|
HS_MINOR_VER=0
|
||||||
HS_BUILD_NUMBER=43
|
HS_BUILD_NUMBER=45
|
||||||
|
|
||||||
JDK_MAJOR_VER=1
|
JDK_MAJOR_VER=1
|
||||||
JDK_MINOR_VER=8
|
JDK_MINOR_VER=8
|
||||||
|
|
|
@ -24,16 +24,20 @@
|
||||||
|
|
||||||
TYPE=MINIMAL1
|
TYPE=MINIMAL1
|
||||||
|
|
||||||
INCLUDE_JVMTI ?= false
|
# Force all variables to false, overriding any other
|
||||||
INCLUDE_FPROF ?= false
|
# setting that may have occurred in the makefiles. These
|
||||||
INCLUDE_VM_STRUCTS ?= false
|
# can still be overridden by passing the variable as an
|
||||||
INCLUDE_JNI_CHECK ?= false
|
# argument to 'make'
|
||||||
INCLUDE_SERVICES ?= false
|
INCLUDE_JVMTI := false
|
||||||
INCLUDE_MANAGEMENT ?= false
|
INCLUDE_FPROF := false
|
||||||
INCLUDE_ALL_GCS ?= false
|
INCLUDE_VM_STRUCTS := false
|
||||||
INCLUDE_NMT ?= false
|
INCLUDE_JNI_CHECK := false
|
||||||
INCLUDE_TRACE ?= false
|
INCLUDE_SERVICES := false
|
||||||
INCLUDE_CDS ?= false
|
INCLUDE_MANAGEMENT := false
|
||||||
|
INCLUDE_ALL_GCS := false
|
||||||
|
INCLUDE_NMT := false
|
||||||
|
INCLUDE_TRACE := false
|
||||||
|
INCLUDE_CDS := false
|
||||||
|
|
||||||
CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
||||||
CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\"
|
||||||
|
|
|
@ -42,7 +42,7 @@ define_pd_global(bool, ProfileInterpreter, false);
|
||||||
#else
|
#else
|
||||||
define_pd_global(bool, ProfileInterpreter, true);
|
define_pd_global(bool, ProfileInterpreter, true);
|
||||||
#endif // CC_INTERP
|
#endif // CC_INTERP
|
||||||
define_pd_global(bool, TieredCompilation, false);
|
define_pd_global(bool, TieredCompilation, trueInTiered);
|
||||||
define_pd_global(intx, CompileThreshold, 10000);
|
define_pd_global(intx, CompileThreshold, 10000);
|
||||||
define_pd_global(intx, BackEdgeThreshold, 140000);
|
define_pd_global(intx, BackEdgeThreshold, 140000);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ define_pd_global(bool, ProfileInterpreter, false);
|
||||||
#else
|
#else
|
||||||
define_pd_global(bool, ProfileInterpreter, true);
|
define_pd_global(bool, ProfileInterpreter, true);
|
||||||
#endif // CC_INTERP
|
#endif // CC_INTERP
|
||||||
define_pd_global(bool, TieredCompilation, false);
|
define_pd_global(bool, TieredCompilation, trueInTiered);
|
||||||
define_pd_global(intx, CompileThreshold, 10000);
|
define_pd_global(intx, CompileThreshold, 10000);
|
||||||
define_pd_global(intx, BackEdgeThreshold, 100000);
|
define_pd_global(intx, BackEdgeThreshold, 100000);
|
||||||
|
|
||||||
|
|
|
@ -2295,7 +2295,7 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
|
||||||
if (gen_type_check) {
|
if (gen_type_check) {
|
||||||
// We have determined that offset == referent_offset && src != null.
|
// We have determined that offset == referent_offset && src != null.
|
||||||
// if (src->_klass->_reference_type == REF_NONE) -> continue
|
// if (src->_klass->_reference_type == REF_NONE) -> continue
|
||||||
__ move(new LIR_Address(src.result(), oopDesc::klass_offset_in_bytes(), UseCompressedKlassPointers ? T_OBJECT : T_ADDRESS), src_klass);
|
__ move(new LIR_Address(src.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), src_klass);
|
||||||
LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
|
LIR_Address* reference_type_addr = new LIR_Address(src_klass, in_bytes(InstanceKlass::reference_type_offset()), T_BYTE);
|
||||||
LIR_Opr reference_type = new_register(T_INT);
|
LIR_Opr reference_type = new_register(T_INT);
|
||||||
__ move(reference_type_addr, reference_type);
|
__ move(reference_type_addr, reference_type);
|
||||||
|
|
|
@ -299,7 +299,7 @@ class CompileReplay : public StackObj {
|
||||||
Symbol* method_signature = parse_symbol(CHECK_NULL);
|
Symbol* method_signature = parse_symbol(CHECK_NULL);
|
||||||
Method* m = k->find_method(method_name, method_signature);
|
Method* m = k->find_method(method_name, method_signature);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
report_error("can't find method");
|
report_error("Can't find method");
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
@ -398,8 +398,8 @@ class CompileReplay : public StackObj {
|
||||||
|
|
||||||
// compile <klass> <name> <signature> <entry_bci> <comp_level>
|
// compile <klass> <name> <signature> <entry_bci> <comp_level>
|
||||||
void process_compile(TRAPS) {
|
void process_compile(TRAPS) {
|
||||||
// methodHandle method;
|
|
||||||
Method* method = parse_method(CHECK);
|
Method* method = parse_method(CHECK);
|
||||||
|
if (had_error()) return;
|
||||||
int entry_bci = parse_int("entry_bci");
|
int entry_bci = parse_int("entry_bci");
|
||||||
const char* comp_level_label = "comp_level";
|
const char* comp_level_label = "comp_level";
|
||||||
int comp_level = parse_int(comp_level_label);
|
int comp_level = parse_int(comp_level_label);
|
||||||
|
@ -440,6 +440,7 @@ class CompileReplay : public StackObj {
|
||||||
//
|
//
|
||||||
void process_ciMethod(TRAPS) {
|
void process_ciMethod(TRAPS) {
|
||||||
Method* method = parse_method(CHECK);
|
Method* method = parse_method(CHECK);
|
||||||
|
if (had_error()) return;
|
||||||
ciMethodRecord* rec = new_ciMethod(method);
|
ciMethodRecord* rec = new_ciMethod(method);
|
||||||
rec->invocation_counter = parse_int("invocation_counter");
|
rec->invocation_counter = parse_int("invocation_counter");
|
||||||
rec->backedge_counter = parse_int("backedge_counter");
|
rec->backedge_counter = parse_int("backedge_counter");
|
||||||
|
@ -451,6 +452,7 @@ class CompileReplay : public StackObj {
|
||||||
// ciMethodData <klass> <name> <signature> <state> <current mileage> orig <length> # # ... data <length> # # ... oops <length>
|
// ciMethodData <klass> <name> <signature> <state> <current mileage> orig <length> # # ... data <length> # # ... oops <length>
|
||||||
void process_ciMethodData(TRAPS) {
|
void process_ciMethodData(TRAPS) {
|
||||||
Method* method = parse_method(CHECK);
|
Method* method = parse_method(CHECK);
|
||||||
|
if (had_error()) return;
|
||||||
/* jsut copied from Method, to build interpret data*/
|
/* jsut copied from Method, to build interpret data*/
|
||||||
if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
|
if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -878,7 +878,7 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) {
|
||||||
|
|
||||||
instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, TRAPS) {
|
instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, TRAPS) {
|
||||||
ResourceMark rm(THREAD);
|
ResourceMark rm(THREAD);
|
||||||
EventMark m("loading class " INTPTR_FORMAT, (address)h_name);
|
EventMark m("loading class %s", h_name->as_C_string());
|
||||||
ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion);
|
ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion);
|
||||||
|
|
||||||
stringStream st;
|
stringStream st;
|
||||||
|
|
|
@ -122,6 +122,22 @@ class MarkRefsIntoClosure: public CMSOopsInGenClosure {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Par_MarkRefsIntoClosure: public CMSOopsInGenClosure {
|
||||||
|
private:
|
||||||
|
const MemRegion _span;
|
||||||
|
CMSBitMap* _bitMap;
|
||||||
|
protected:
|
||||||
|
DO_OOP_WORK_DEFN
|
||||||
|
public:
|
||||||
|
Par_MarkRefsIntoClosure(MemRegion span, CMSBitMap* bitMap);
|
||||||
|
virtual void do_oop(oop* p);
|
||||||
|
virtual void do_oop(narrowOop* p);
|
||||||
|
|
||||||
|
Prefetch::style prefetch_style() {
|
||||||
|
return Prefetch::do_read;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// A variant of the above used in certain kinds of CMS
|
// A variant of the above used in certain kinds of CMS
|
||||||
// marking verification.
|
// marking verification.
|
||||||
class MarkRefsIntoVerifyClosure: public CMSOopsInGenClosure {
|
class MarkRefsIntoVerifyClosure: public CMSOopsInGenClosure {
|
||||||
|
|
|
@ -569,6 +569,7 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
|
||||||
_restart_addr(NULL),
|
_restart_addr(NULL),
|
||||||
_overflow_list(NULL),
|
_overflow_list(NULL),
|
||||||
_stats(cmsGen),
|
_stats(cmsGen),
|
||||||
|
_eden_chunk_lock(new Mutex(Mutex::leaf + 1, "CMS_eden_chunk_lock", true)),
|
||||||
_eden_chunk_array(NULL), // may be set in ctor body
|
_eden_chunk_array(NULL), // may be set in ctor body
|
||||||
_eden_chunk_capacity(0), // -- ditto --
|
_eden_chunk_capacity(0), // -- ditto --
|
||||||
_eden_chunk_index(0), // -- ditto --
|
_eden_chunk_index(0), // -- ditto --
|
||||||
|
@ -732,7 +733,7 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
|
||||||
assert(_eden_chunk_array != NULL || _eden_chunk_capacity == 0, "Error");
|
assert(_eden_chunk_array != NULL || _eden_chunk_capacity == 0, "Error");
|
||||||
|
|
||||||
// Support for parallelizing survivor space rescan
|
// Support for parallelizing survivor space rescan
|
||||||
if (CMSParallelRemarkEnabled && CMSParallelSurvivorRemarkEnabled) {
|
if ((CMSParallelRemarkEnabled && CMSParallelSurvivorRemarkEnabled) || CMSParallelInitialMarkEnabled) {
|
||||||
const size_t max_plab_samples =
|
const size_t max_plab_samples =
|
||||||
((DefNewGeneration*)_young_gen)->max_survivor_size()/MinTLABSize;
|
((DefNewGeneration*)_young_gen)->max_survivor_size()/MinTLABSize;
|
||||||
|
|
||||||
|
@ -2137,6 +2138,39 @@ void CMSCollector::do_mark_sweep_work(bool clear_all_soft_refs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMSCollector::print_eden_and_survivor_chunk_arrays() {
|
||||||
|
DefNewGeneration* dng = _young_gen->as_DefNewGeneration();
|
||||||
|
EdenSpace* eden_space = dng->eden();
|
||||||
|
ContiguousSpace* from_space = dng->from();
|
||||||
|
ContiguousSpace* to_space = dng->to();
|
||||||
|
// Eden
|
||||||
|
if (_eden_chunk_array != NULL) {
|
||||||
|
gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
|
||||||
|
eden_space->bottom(), eden_space->top(),
|
||||||
|
eden_space->end(), eden_space->capacity());
|
||||||
|
gclog_or_tty->print_cr("_eden_chunk_index=" SIZE_FORMAT ", "
|
||||||
|
"_eden_chunk_capacity=" SIZE_FORMAT,
|
||||||
|
_eden_chunk_index, _eden_chunk_capacity);
|
||||||
|
for (size_t i = 0; i < _eden_chunk_index; i++) {
|
||||||
|
gclog_or_tty->print_cr("_eden_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
|
||||||
|
i, _eden_chunk_array[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Survivor
|
||||||
|
if (_survivor_chunk_array != NULL) {
|
||||||
|
gclog_or_tty->print_cr("survivor " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
|
||||||
|
from_space->bottom(), from_space->top(),
|
||||||
|
from_space->end(), from_space->capacity());
|
||||||
|
gclog_or_tty->print_cr("_survivor_chunk_index=" SIZE_FORMAT ", "
|
||||||
|
"_survivor_chunk_capacity=" SIZE_FORMAT,
|
||||||
|
_survivor_chunk_index, _survivor_chunk_capacity);
|
||||||
|
for (size_t i = 0; i < _survivor_chunk_index; i++) {
|
||||||
|
gclog_or_tty->print_cr("_survivor_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
|
||||||
|
i, _survivor_chunk_array[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMSCollector::getFreelistLocks() const {
|
void CMSCollector::getFreelistLocks() const {
|
||||||
// Get locks for all free lists in all generations that this
|
// Get locks for all free lists in all generations that this
|
||||||
// collector is responsible for
|
// collector is responsible for
|
||||||
|
@ -3549,6 +3583,31 @@ CMSPhaseAccounting::~CMSPhaseAccounting() {
|
||||||
|
|
||||||
// CMS work
|
// CMS work
|
||||||
|
|
||||||
|
// The common parts of CMSParInitialMarkTask and CMSParRemarkTask.
|
||||||
|
class CMSParMarkTask : public AbstractGangTask {
|
||||||
|
protected:
|
||||||
|
CMSCollector* _collector;
|
||||||
|
int _n_workers;
|
||||||
|
CMSParMarkTask(const char* name, CMSCollector* collector, int n_workers) :
|
||||||
|
AbstractGangTask(name),
|
||||||
|
_collector(collector),
|
||||||
|
_n_workers(n_workers) {}
|
||||||
|
// Work method in support of parallel rescan ... of young gen spaces
|
||||||
|
void do_young_space_rescan(uint worker_id, OopsInGenClosure* cl,
|
||||||
|
ContiguousSpace* space,
|
||||||
|
HeapWord** chunk_array, size_t chunk_top);
|
||||||
|
void work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parallel initial mark task
|
||||||
|
class CMSParInitialMarkTask: public CMSParMarkTask {
|
||||||
|
public:
|
||||||
|
CMSParInitialMarkTask(CMSCollector* collector, int n_workers) :
|
||||||
|
CMSParMarkTask("Scan roots and young gen for initial mark in parallel",
|
||||||
|
collector, n_workers) {}
|
||||||
|
void work(uint worker_id);
|
||||||
|
};
|
||||||
|
|
||||||
// Checkpoint the roots into this generation from outside
|
// Checkpoint the roots into this generation from outside
|
||||||
// this generation. [Note this initial checkpoint need only
|
// this generation. [Note this initial checkpoint need only
|
||||||
// be approximate -- we'll do a catch up phase subsequently.]
|
// be approximate -- we'll do a catch up phase subsequently.]
|
||||||
|
@ -3646,19 +3705,42 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) {
|
||||||
// the klasses. The claimed marks need to be cleared before marking starts.
|
// the klasses. The claimed marks need to be cleared before marking starts.
|
||||||
ClassLoaderDataGraph::clear_claimed_marks();
|
ClassLoaderDataGraph::clear_claimed_marks();
|
||||||
|
|
||||||
CMKlassClosure klass_closure(¬Older);
|
if (CMSPrintEdenSurvivorChunks) {
|
||||||
|
print_eden_and_survivor_chunk_arrays();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
|
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
|
||||||
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
|
if (CMSParallelInitialMarkEnabled && CollectedHeap::use_parallel_gc_threads()) {
|
||||||
gch->gen_process_strong_roots(_cmsGen->level(),
|
// The parallel version.
|
||||||
true, // younger gens are roots
|
FlexibleWorkGang* workers = gch->workers();
|
||||||
true, // activate StrongRootsScope
|
assert(workers != NULL, "Need parallel worker threads.");
|
||||||
false, // not scavenging
|
int n_workers = workers->active_workers();
|
||||||
SharedHeap::ScanningOption(roots_scanning_options()),
|
CMSParInitialMarkTask tsk(this, n_workers);
|
||||||
¬Older,
|
gch->set_par_threads(n_workers);
|
||||||
true, // walk all of code cache if (so & SO_CodeCache)
|
initialize_sequential_subtasks_for_young_gen_rescan(n_workers);
|
||||||
NULL,
|
if (n_workers > 1) {
|
||||||
&klass_closure);
|
GenCollectedHeap::StrongRootsScope srs(gch);
|
||||||
|
workers->run_task(&tsk);
|
||||||
|
} else {
|
||||||
|
GenCollectedHeap::StrongRootsScope srs(gch);
|
||||||
|
tsk.work(0);
|
||||||
|
}
|
||||||
|
gch->set_par_threads(0);
|
||||||
|
} else {
|
||||||
|
// The serial version.
|
||||||
|
CMKlassClosure klass_closure(¬Older);
|
||||||
|
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
|
||||||
|
gch->gen_process_strong_roots(_cmsGen->level(),
|
||||||
|
true, // younger gens are roots
|
||||||
|
true, // activate StrongRootsScope
|
||||||
|
false, // not scavenging
|
||||||
|
SharedHeap::ScanningOption(roots_scanning_options()),
|
||||||
|
¬Older,
|
||||||
|
true, // walk all of code cache if (so & SO_CodeCache)
|
||||||
|
NULL,
|
||||||
|
&klass_closure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear mod-union table; it will be dirtied in the prologue of
|
// Clear mod-union table; it will be dirtied in the prologue of
|
||||||
|
@ -4417,7 +4499,9 @@ void CMSCollector::preclean() {
|
||||||
verify_overflow_empty();
|
verify_overflow_empty();
|
||||||
_abort_preclean = false;
|
_abort_preclean = false;
|
||||||
if (CMSPrecleaningEnabled) {
|
if (CMSPrecleaningEnabled) {
|
||||||
_eden_chunk_index = 0;
|
if (!CMSEdenChunksRecordAlways) {
|
||||||
|
_eden_chunk_index = 0;
|
||||||
|
}
|
||||||
size_t used = get_eden_used();
|
size_t used = get_eden_used();
|
||||||
size_t capacity = get_eden_capacity();
|
size_t capacity = get_eden_capacity();
|
||||||
// Don't start sampling unless we will get sufficiently
|
// Don't start sampling unless we will get sufficiently
|
||||||
|
@ -4526,7 +4610,9 @@ void CMSCollector::sample_eden() {
|
||||||
if (!_start_sampling) {
|
if (!_start_sampling) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_eden_chunk_array) {
|
// When CMSEdenChunksRecordAlways is true, the eden chunk array
|
||||||
|
// is populated by the young generation.
|
||||||
|
if (_eden_chunk_array != NULL && !CMSEdenChunksRecordAlways) {
|
||||||
if (_eden_chunk_index < _eden_chunk_capacity) {
|
if (_eden_chunk_index < _eden_chunk_capacity) {
|
||||||
_eden_chunk_array[_eden_chunk_index] = *_top_addr; // take sample
|
_eden_chunk_array[_eden_chunk_index] = *_top_addr; // take sample
|
||||||
assert(_eden_chunk_array[_eden_chunk_index] <= *_end_addr,
|
assert(_eden_chunk_array[_eden_chunk_index] <= *_end_addr,
|
||||||
|
@ -5010,6 +5096,10 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch,
|
||||||
// Update the saved marks which may affect the root scans.
|
// Update the saved marks which may affect the root scans.
|
||||||
gch->save_marks();
|
gch->save_marks();
|
||||||
|
|
||||||
|
if (CMSPrintEdenSurvivorChunks) {
|
||||||
|
print_eden_and_survivor_chunk_arrays();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
|
COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
|
||||||
|
|
||||||
|
@ -5116,10 +5206,53 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMSParInitialMarkTask::work(uint worker_id) {
|
||||||
|
elapsedTimer _timer;
|
||||||
|
ResourceMark rm;
|
||||||
|
HandleMark hm;
|
||||||
|
|
||||||
|
// ---------- scan from roots --------------
|
||||||
|
_timer.start();
|
||||||
|
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
||||||
|
Par_MarkRefsIntoClosure par_mri_cl(_collector->_span, &(_collector->_markBitMap));
|
||||||
|
CMKlassClosure klass_closure(&par_mri_cl);
|
||||||
|
|
||||||
|
// ---------- young gen roots --------------
|
||||||
|
{
|
||||||
|
work_on_young_gen_roots(worker_id, &par_mri_cl);
|
||||||
|
_timer.stop();
|
||||||
|
if (PrintCMSStatistics != 0) {
|
||||||
|
gclog_or_tty->print_cr(
|
||||||
|
"Finished young gen initial mark scan work in %dth thread: %3.3f sec",
|
||||||
|
worker_id, _timer.seconds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- remaining roots --------------
|
||||||
|
_timer.reset();
|
||||||
|
_timer.start();
|
||||||
|
gch->gen_process_strong_roots(_collector->_cmsGen->level(),
|
||||||
|
false, // yg was scanned above
|
||||||
|
false, // this is parallel code
|
||||||
|
false, // not scavenging
|
||||||
|
SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
|
||||||
|
&par_mri_cl,
|
||||||
|
true, // walk all of code cache if (so & SO_CodeCache)
|
||||||
|
NULL,
|
||||||
|
&klass_closure);
|
||||||
|
assert(_collector->should_unload_classes()
|
||||||
|
|| (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_CodeCache),
|
||||||
|
"if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
|
||||||
|
_timer.stop();
|
||||||
|
if (PrintCMSStatistics != 0) {
|
||||||
|
gclog_or_tty->print_cr(
|
||||||
|
"Finished remaining root initial mark scan work in %dth thread: %3.3f sec",
|
||||||
|
worker_id, _timer.seconds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parallel remark task
|
// Parallel remark task
|
||||||
class CMSParRemarkTask: public AbstractGangTask {
|
class CMSParRemarkTask: public CMSParMarkTask {
|
||||||
CMSCollector* _collector;
|
|
||||||
int _n_workers;
|
|
||||||
CompactibleFreeListSpace* _cms_space;
|
CompactibleFreeListSpace* _cms_space;
|
||||||
|
|
||||||
// The per-thread work queues, available here for stealing.
|
// The per-thread work queues, available here for stealing.
|
||||||
|
@ -5133,10 +5266,9 @@ class CMSParRemarkTask: public AbstractGangTask {
|
||||||
CompactibleFreeListSpace* cms_space,
|
CompactibleFreeListSpace* cms_space,
|
||||||
int n_workers, FlexibleWorkGang* workers,
|
int n_workers, FlexibleWorkGang* workers,
|
||||||
OopTaskQueueSet* task_queues):
|
OopTaskQueueSet* task_queues):
|
||||||
AbstractGangTask("Rescan roots and grey objects in parallel"),
|
CMSParMarkTask("Rescan roots and grey objects in parallel",
|
||||||
_collector(collector),
|
collector, n_workers),
|
||||||
_cms_space(cms_space),
|
_cms_space(cms_space),
|
||||||
_n_workers(n_workers),
|
|
||||||
_task_queues(task_queues),
|
_task_queues(task_queues),
|
||||||
_term(n_workers, task_queues) { }
|
_term(n_workers, task_queues) { }
|
||||||
|
|
||||||
|
@ -5150,11 +5282,6 @@ class CMSParRemarkTask: public AbstractGangTask {
|
||||||
void work(uint worker_id);
|
void work(uint worker_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Work method in support of parallel rescan ... of young gen spaces
|
|
||||||
void do_young_space_rescan(int i, Par_MarkRefsIntoAndScanClosure* cl,
|
|
||||||
ContiguousSpace* space,
|
|
||||||
HeapWord** chunk_array, size_t chunk_top);
|
|
||||||
|
|
||||||
// ... of dirty cards in old space
|
// ... of dirty cards in old space
|
||||||
void do_dirty_card_rescan_tasks(CompactibleFreeListSpace* sp, int i,
|
void do_dirty_card_rescan_tasks(CompactibleFreeListSpace* sp, int i,
|
||||||
Par_MarkRefsIntoAndScanClosure* cl);
|
Par_MarkRefsIntoAndScanClosure* cl);
|
||||||
|
@ -5186,6 +5313,25 @@ class RemarkKlassClosure : public KlassClosure {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) {
|
||||||
|
DefNewGeneration* dng = _collector->_young_gen->as_DefNewGeneration();
|
||||||
|
EdenSpace* eden_space = dng->eden();
|
||||||
|
ContiguousSpace* from_space = dng->from();
|
||||||
|
ContiguousSpace* to_space = dng->to();
|
||||||
|
|
||||||
|
HeapWord** eca = _collector->_eden_chunk_array;
|
||||||
|
size_t ect = _collector->_eden_chunk_index;
|
||||||
|
HeapWord** sca = _collector->_survivor_chunk_array;
|
||||||
|
size_t sct = _collector->_survivor_chunk_index;
|
||||||
|
|
||||||
|
assert(ect <= _collector->_eden_chunk_capacity, "out of bounds");
|
||||||
|
assert(sct <= _collector->_survivor_chunk_capacity, "out of bounds");
|
||||||
|
|
||||||
|
do_young_space_rescan(worker_id, cl, to_space, NULL, 0);
|
||||||
|
do_young_space_rescan(worker_id, cl, from_space, sca, sct);
|
||||||
|
do_young_space_rescan(worker_id, cl, eden_space, eca, ect);
|
||||||
|
}
|
||||||
|
|
||||||
// work_queue(i) is passed to the closure
|
// work_queue(i) is passed to the closure
|
||||||
// Par_MarkRefsIntoAndScanClosure. The "i" parameter
|
// Par_MarkRefsIntoAndScanClosure. The "i" parameter
|
||||||
// also is passed to do_dirty_card_rescan_tasks() and to
|
// also is passed to do_dirty_card_rescan_tasks() and to
|
||||||
|
@ -5210,23 +5356,7 @@ void CMSParRemarkTask::work(uint worker_id) {
|
||||||
// work first.
|
// work first.
|
||||||
// ---------- young gen roots --------------
|
// ---------- young gen roots --------------
|
||||||
{
|
{
|
||||||
DefNewGeneration* dng = _collector->_young_gen->as_DefNewGeneration();
|
work_on_young_gen_roots(worker_id, &par_mrias_cl);
|
||||||
EdenSpace* eden_space = dng->eden();
|
|
||||||
ContiguousSpace* from_space = dng->from();
|
|
||||||
ContiguousSpace* to_space = dng->to();
|
|
||||||
|
|
||||||
HeapWord** eca = _collector->_eden_chunk_array;
|
|
||||||
size_t ect = _collector->_eden_chunk_index;
|
|
||||||
HeapWord** sca = _collector->_survivor_chunk_array;
|
|
||||||
size_t sct = _collector->_survivor_chunk_index;
|
|
||||||
|
|
||||||
assert(ect <= _collector->_eden_chunk_capacity, "out of bounds");
|
|
||||||
assert(sct <= _collector->_survivor_chunk_capacity, "out of bounds");
|
|
||||||
|
|
||||||
do_young_space_rescan(worker_id, &par_mrias_cl, to_space, NULL, 0);
|
|
||||||
do_young_space_rescan(worker_id, &par_mrias_cl, from_space, sca, sct);
|
|
||||||
do_young_space_rescan(worker_id, &par_mrias_cl, eden_space, eca, ect);
|
|
||||||
|
|
||||||
_timer.stop();
|
_timer.stop();
|
||||||
if (PrintCMSStatistics != 0) {
|
if (PrintCMSStatistics != 0) {
|
||||||
gclog_or_tty->print_cr(
|
gclog_or_tty->print_cr(
|
||||||
|
@ -5334,8 +5464,8 @@ void CMSParRemarkTask::work(uint worker_id) {
|
||||||
|
|
||||||
// Note that parameter "i" is not used.
|
// Note that parameter "i" is not used.
|
||||||
void
|
void
|
||||||
CMSParRemarkTask::do_young_space_rescan(int i,
|
CMSParMarkTask::do_young_space_rescan(uint worker_id,
|
||||||
Par_MarkRefsIntoAndScanClosure* cl, ContiguousSpace* space,
|
OopsInGenClosure* cl, ContiguousSpace* space,
|
||||||
HeapWord** chunk_array, size_t chunk_top) {
|
HeapWord** chunk_array, size_t chunk_top) {
|
||||||
// Until all tasks completed:
|
// Until all tasks completed:
|
||||||
// . claim an unclaimed task
|
// . claim an unclaimed task
|
||||||
|
@ -5530,6 +5660,32 @@ CMSParRemarkTask::do_work_steal(int i, Par_MarkRefsIntoAndScanClosure* cl,
|
||||||
"Else our work is not yet done");
|
"Else our work is not yet done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Record object boundaries in _eden_chunk_array by sampling the eden
|
||||||
|
// top in the slow-path eden object allocation code path and record
|
||||||
|
// the boundaries, if CMSEdenChunksRecordAlways is true. If
|
||||||
|
// CMSEdenChunksRecordAlways is false, we use the other asynchronous
|
||||||
|
// sampling in sample_eden() that activates during the part of the
|
||||||
|
// preclean phase.
|
||||||
|
void CMSCollector::sample_eden_chunk() {
|
||||||
|
if (CMSEdenChunksRecordAlways && _eden_chunk_array != NULL) {
|
||||||
|
if (_eden_chunk_lock->try_lock()) {
|
||||||
|
// Record a sample. This is the critical section. The contents
|
||||||
|
// of the _eden_chunk_array have to be non-decreasing in the
|
||||||
|
// address order.
|
||||||
|
_eden_chunk_array[_eden_chunk_index] = *_top_addr;
|
||||||
|
assert(_eden_chunk_array[_eden_chunk_index] <= *_end_addr,
|
||||||
|
"Unexpected state of Eden");
|
||||||
|
if (_eden_chunk_index == 0 ||
|
||||||
|
((_eden_chunk_array[_eden_chunk_index] > _eden_chunk_array[_eden_chunk_index-1]) &&
|
||||||
|
(pointer_delta(_eden_chunk_array[_eden_chunk_index],
|
||||||
|
_eden_chunk_array[_eden_chunk_index-1]) >= CMSSamplingGrain))) {
|
||||||
|
_eden_chunk_index++; // commit sample
|
||||||
|
}
|
||||||
|
_eden_chunk_lock->unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return a thread-local PLAB recording array, as appropriate.
|
// Return a thread-local PLAB recording array, as appropriate.
|
||||||
void* CMSCollector::get_data_recorder(int thr_num) {
|
void* CMSCollector::get_data_recorder(int thr_num) {
|
||||||
if (_survivor_plab_array != NULL &&
|
if (_survivor_plab_array != NULL &&
|
||||||
|
@ -5553,12 +5709,13 @@ void CMSCollector::reset_survivor_plab_arrays() {
|
||||||
|
|
||||||
// Merge the per-thread plab arrays into the global survivor chunk
|
// Merge the per-thread plab arrays into the global survivor chunk
|
||||||
// array which will provide the partitioning of the survivor space
|
// array which will provide the partitioning of the survivor space
|
||||||
// for CMS rescan.
|
// for CMS initial scan and rescan.
|
||||||
void CMSCollector::merge_survivor_plab_arrays(ContiguousSpace* surv,
|
void CMSCollector::merge_survivor_plab_arrays(ContiguousSpace* surv,
|
||||||
int no_of_gc_threads) {
|
int no_of_gc_threads) {
|
||||||
assert(_survivor_plab_array != NULL, "Error");
|
assert(_survivor_plab_array != NULL, "Error");
|
||||||
assert(_survivor_chunk_array != NULL, "Error");
|
assert(_survivor_chunk_array != NULL, "Error");
|
||||||
assert(_collectorState == FinalMarking, "Error");
|
assert(_collectorState == FinalMarking ||
|
||||||
|
(CMSParallelInitialMarkEnabled && _collectorState == InitialMarking), "Error");
|
||||||
for (int j = 0; j < no_of_gc_threads; j++) {
|
for (int j = 0; j < no_of_gc_threads; j++) {
|
||||||
_cursor[j] = 0;
|
_cursor[j] = 0;
|
||||||
}
|
}
|
||||||
|
@ -5621,7 +5778,7 @@ void CMSCollector::merge_survivor_plab_arrays(ContiguousSpace* surv,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the space's par_seq_tasks structure for work claiming
|
// Set up the space's par_seq_tasks structure for work claiming
|
||||||
// for parallel rescan of young gen.
|
// for parallel initial scan and rescan of young gen.
|
||||||
// See ParRescanTask where this is currently used.
|
// See ParRescanTask where this is currently used.
|
||||||
void
|
void
|
||||||
CMSCollector::
|
CMSCollector::
|
||||||
|
@ -6748,6 +6905,28 @@ void MarkRefsIntoClosure::do_oop(oop obj) {
|
||||||
void MarkRefsIntoClosure::do_oop(oop* p) { MarkRefsIntoClosure::do_oop_work(p); }
|
void MarkRefsIntoClosure::do_oop(oop* p) { MarkRefsIntoClosure::do_oop_work(p); }
|
||||||
void MarkRefsIntoClosure::do_oop(narrowOop* p) { MarkRefsIntoClosure::do_oop_work(p); }
|
void MarkRefsIntoClosure::do_oop(narrowOop* p) { MarkRefsIntoClosure::do_oop_work(p); }
|
||||||
|
|
||||||
|
Par_MarkRefsIntoClosure::Par_MarkRefsIntoClosure(
|
||||||
|
MemRegion span, CMSBitMap* bitMap):
|
||||||
|
_span(span),
|
||||||
|
_bitMap(bitMap)
|
||||||
|
{
|
||||||
|
assert(_ref_processor == NULL, "deliberately left NULL");
|
||||||
|
assert(_bitMap->covers(_span), "_bitMap/_span mismatch");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Par_MarkRefsIntoClosure::do_oop(oop obj) {
|
||||||
|
// if p points into _span, then mark corresponding bit in _markBitMap
|
||||||
|
assert(obj->is_oop(), "expected an oop");
|
||||||
|
HeapWord* addr = (HeapWord*)obj;
|
||||||
|
if (_span.contains(addr)) {
|
||||||
|
// this should be made more efficient
|
||||||
|
_bitMap->par_mark(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Par_MarkRefsIntoClosure::do_oop(oop* p) { Par_MarkRefsIntoClosure::do_oop_work(p); }
|
||||||
|
void Par_MarkRefsIntoClosure::do_oop(narrowOop* p) { Par_MarkRefsIntoClosure::do_oop_work(p); }
|
||||||
|
|
||||||
// A variant of the above, used for CMS marking verification.
|
// A variant of the above, used for CMS marking verification.
|
||||||
MarkRefsIntoVerifyClosure::MarkRefsIntoVerifyClosure(
|
MarkRefsIntoVerifyClosure::MarkRefsIntoVerifyClosure(
|
||||||
MemRegion span, CMSBitMap* verification_bm, CMSBitMap* cms_bm):
|
MemRegion span, CMSBitMap* verification_bm, CMSBitMap* cms_bm):
|
||||||
|
@ -9305,7 +9484,6 @@ void ASConcurrentMarkSweepGeneration::shrink_by(size_t desired_bytes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer some number of overflown objects to usual marking
|
// Transfer some number of overflown objects to usual marking
|
||||||
// stack. Return true if some objects were transferred.
|
// stack. Return true if some objects were transferred.
|
||||||
bool MarkRefsIntoAndScanClosure::take_from_overflow_list() {
|
bool MarkRefsIntoAndScanClosure::take_from_overflow_list() {
|
||||||
|
@ -9377,4 +9555,3 @@ TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(CMSCollector::CollectorSt
|
||||||
ShouldNotReachHere();
|
ShouldNotReachHere();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,6 +515,8 @@ class CMSCollector: public CHeapObj<mtGC> {
|
||||||
friend class ConcurrentMarkSweepThread;
|
friend class ConcurrentMarkSweepThread;
|
||||||
friend class ConcurrentMarkSweepGeneration;
|
friend class ConcurrentMarkSweepGeneration;
|
||||||
friend class CompactibleFreeListSpace;
|
friend class CompactibleFreeListSpace;
|
||||||
|
friend class CMSParMarkTask;
|
||||||
|
friend class CMSParInitialMarkTask;
|
||||||
friend class CMSParRemarkTask;
|
friend class CMSParRemarkTask;
|
||||||
friend class CMSConcMarkingTask;
|
friend class CMSConcMarkingTask;
|
||||||
friend class CMSRefProcTaskProxy;
|
friend class CMSRefProcTaskProxy;
|
||||||
|
@ -749,6 +751,7 @@ class CMSCollector: public CHeapObj<mtGC> {
|
||||||
Generation* _young_gen; // the younger gen
|
Generation* _young_gen; // the younger gen
|
||||||
HeapWord** _top_addr; // ... Top of Eden
|
HeapWord** _top_addr; // ... Top of Eden
|
||||||
HeapWord** _end_addr; // ... End of Eden
|
HeapWord** _end_addr; // ... End of Eden
|
||||||
|
Mutex* _eden_chunk_lock;
|
||||||
HeapWord** _eden_chunk_array; // ... Eden partitioning array
|
HeapWord** _eden_chunk_array; // ... Eden partitioning array
|
||||||
size_t _eden_chunk_index; // ... top (exclusive) of array
|
size_t _eden_chunk_index; // ... top (exclusive) of array
|
||||||
size_t _eden_chunk_capacity; // ... max entries in array
|
size_t _eden_chunk_capacity; // ... max entries in array
|
||||||
|
@ -950,6 +953,7 @@ class CMSCollector: public CHeapObj<mtGC> {
|
||||||
|
|
||||||
// Support for parallel remark of survivor space
|
// Support for parallel remark of survivor space
|
||||||
void* get_data_recorder(int thr_num);
|
void* get_data_recorder(int thr_num);
|
||||||
|
void sample_eden_chunk();
|
||||||
|
|
||||||
CMSBitMap* markBitMap() { return &_markBitMap; }
|
CMSBitMap* markBitMap() { return &_markBitMap; }
|
||||||
void directAllocated(HeapWord* start, size_t size);
|
void directAllocated(HeapWord* start, size_t size);
|
||||||
|
@ -1027,6 +1031,8 @@ class CMSCollector: public CHeapObj<mtGC> {
|
||||||
|
|
||||||
// Initialization errors
|
// Initialization errors
|
||||||
bool completed_initialization() { return _completed_initialization; }
|
bool completed_initialization() { return _completed_initialization; }
|
||||||
|
|
||||||
|
void print_eden_and_survivor_chunk_arrays();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMSExpansionCause : public AllStatic {
|
class CMSExpansionCause : public AllStatic {
|
||||||
|
@ -1317,6 +1323,10 @@ class ConcurrentMarkSweepGeneration: public CardGeneration {
|
||||||
//Delegate to collector
|
//Delegate to collector
|
||||||
return collector()->get_data_recorder(thr_num);
|
return collector()->get_data_recorder(thr_num);
|
||||||
}
|
}
|
||||||
|
void sample_eden_chunk() {
|
||||||
|
//Delegate to collector
|
||||||
|
return collector()->sample_eden_chunk();
|
||||||
|
}
|
||||||
|
|
||||||
// Printing
|
// Printing
|
||||||
const char* name() const;
|
const char* name() const;
|
||||||
|
|
|
@ -96,11 +96,6 @@
|
||||||
"the buffer will be enqueued for processing. A value of 0 " \
|
"the buffer will be enqueued for processing. A value of 0 " \
|
||||||
"specifies that mutator threads should not do such filtering.") \
|
"specifies that mutator threads should not do such filtering.") \
|
||||||
\
|
\
|
||||||
develop(intx, G1ExtraRegionSurvRate, 33, \
|
|
||||||
"If the young survival rate is S, and there's room left in " \
|
|
||||||
"to-space, we will allow regions whose survival rate is up to " \
|
|
||||||
"S + (1 - S)*X, where X is this parameter (as a fraction.)") \
|
|
||||||
\
|
|
||||||
develop(bool, G1SATBPrintStubs, false, \
|
develop(bool, G1SATBPrintStubs, false, \
|
||||||
"If true, print generated stubs for the SATB barrier") \
|
"If true, print generated stubs for the SATB barrier") \
|
||||||
\
|
\
|
||||||
|
@ -110,9 +105,6 @@
|
||||||
develop(bool, G1RSBarrierRegionFilter, true, \
|
develop(bool, G1RSBarrierRegionFilter, true, \
|
||||||
"If true, generate region filtering code in RS barrier") \
|
"If true, generate region filtering code in RS barrier") \
|
||||||
\
|
\
|
||||||
develop(bool, G1RSBarrierNullFilter, true, \
|
|
||||||
"If true, generate null-pointer filtering code in RS barrier") \
|
|
||||||
\
|
|
||||||
develop(bool, G1DeferredRSUpdate, true, \
|
develop(bool, G1DeferredRSUpdate, true, \
|
||||||
"If true, use deferred RS updates") \
|
"If true, use deferred RS updates") \
|
||||||
\
|
\
|
||||||
|
@ -120,9 +112,6 @@
|
||||||
"If true, verify that no dirty cards remain after RS log " \
|
"If true, verify that no dirty cards remain after RS log " \
|
||||||
"processing.") \
|
"processing.") \
|
||||||
\
|
\
|
||||||
develop(bool, G1RSCountHisto, false, \
|
|
||||||
"If true, print a histogram of RS occupancies after each pause") \
|
|
||||||
\
|
|
||||||
diagnostic(bool, G1PrintRegionLivenessInfo, false, \
|
diagnostic(bool, G1PrintRegionLivenessInfo, false, \
|
||||||
"Prints the liveness information for all regions in the heap " \
|
"Prints the liveness information for all regions in the heap " \
|
||||||
"at the end of a marking cycle.") \
|
"at the end of a marking cycle.") \
|
||||||
|
@ -169,9 +158,6 @@
|
||||||
product(uintx, G1ConcRSHotCardLimit, 4, \
|
product(uintx, G1ConcRSHotCardLimit, 4, \
|
||||||
"The threshold that defines (>=) a hot card.") \
|
"The threshold that defines (>=) a hot card.") \
|
||||||
\
|
\
|
||||||
develop(bool, G1PrintOopAppls, false, \
|
|
||||||
"When true, print applications of closures to external locs.") \
|
|
||||||
\
|
|
||||||
develop(intx, G1RSetRegionEntriesBase, 256, \
|
develop(intx, G1RSetRegionEntriesBase, 256, \
|
||||||
"Max number of regions in a fine-grain table per MB.") \
|
"Max number of regions in a fine-grain table per MB.") \
|
||||||
\
|
\
|
||||||
|
|
|
@ -314,6 +314,11 @@ void HeapRegion::setup_heap_region_size(uintx min_heap_size) {
|
||||||
region_size = MAX_REGION_SIZE;
|
region_size = MAX_REGION_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (region_size != G1HeapRegionSize) {
|
||||||
|
// Update the flag to make sure that PrintFlagsFinal logs the correct value
|
||||||
|
FLAG_SET_ERGO(uintx, G1HeapRegionSize, region_size);
|
||||||
|
}
|
||||||
|
|
||||||
// And recalculate the log.
|
// And recalculate the log.
|
||||||
region_size_log = log2_long((jlong) region_size);
|
region_size_log = log2_long((jlong) region_size);
|
||||||
|
|
||||||
|
|
|
@ -1033,6 +1033,9 @@ HeapWord* DefNewGeneration::allocate(size_t word_size,
|
||||||
// have to use it here, as well.
|
// have to use it here, as well.
|
||||||
HeapWord* result = eden()->par_allocate(word_size);
|
HeapWord* result = eden()->par_allocate(word_size);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
|
if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
|
||||||
|
_next_gen->sample_eden_chunk();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
|
@ -1063,13 +1066,19 @@ HeapWord* DefNewGeneration::allocate(size_t word_size,
|
||||||
// circular dependency at compile time.
|
// circular dependency at compile time.
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
result = allocate_from_space(word_size);
|
result = allocate_from_space(word_size);
|
||||||
|
} else if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
|
||||||
|
_next_gen->sample_eden_chunk();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* DefNewGeneration::par_allocate(size_t word_size,
|
HeapWord* DefNewGeneration::par_allocate(size_t word_size,
|
||||||
bool is_tlab) {
|
bool is_tlab) {
|
||||||
return eden()->par_allocate(word_size);
|
HeapWord* res = eden()->par_allocate(word_size);
|
||||||
|
if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
|
||||||
|
_next_gen->sample_eden_chunk();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefNewGeneration::gc_prologue(bool full) {
|
void DefNewGeneration::gc_prologue(bool full) {
|
||||||
|
|
|
@ -455,6 +455,7 @@ class Generation: public CHeapObj<mtGC> {
|
||||||
// expected to be GC worker thread-local, with the worker index
|
// expected to be GC worker thread-local, with the worker index
|
||||||
// indicated by "thr_num".
|
// indicated by "thr_num".
|
||||||
virtual void* get_data_recorder(int thr_num) { return NULL; }
|
virtual void* get_data_recorder(int thr_num) { return NULL; }
|
||||||
|
virtual void sample_eden_chunk() {}
|
||||||
|
|
||||||
// Some generations may require some cleanup actions before allowing
|
// Some generations may require some cleanup actions before allowing
|
||||||
// a verification.
|
// a verification.
|
||||||
|
|
|
@ -2254,10 +2254,11 @@ ChunkIndex ChunkManager::list_index(size_t size) {
|
||||||
|
|
||||||
void SpaceManager::deallocate(MetaWord* p, size_t word_size) {
|
void SpaceManager::deallocate(MetaWord* p, size_t word_size) {
|
||||||
assert_lock_strong(_lock);
|
assert_lock_strong(_lock);
|
||||||
|
size_t raw_word_size = get_raw_word_size(word_size);
|
||||||
size_t min_size = TreeChunk<Metablock, FreeList>::min_size();
|
size_t min_size = TreeChunk<Metablock, FreeList>::min_size();
|
||||||
assert(word_size >= min_size,
|
assert(raw_word_size >= min_size,
|
||||||
err_msg("Should not deallocate dark matter " SIZE_FORMAT, word_size));
|
err_msg("Should not deallocate dark matter " SIZE_FORMAT, word_size));
|
||||||
block_freelists()->return_block(p, word_size);
|
block_freelists()->return_block(p, raw_word_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds a chunk to the list of chunks in use.
|
// Adds a chunk to the list of chunks in use.
|
||||||
|
|
|
@ -65,7 +65,8 @@ SharedHeap::SharedHeap(CollectorPolicy* policy_) :
|
||||||
}
|
}
|
||||||
_sh = this; // ch is static, should be set only once.
|
_sh = this; // ch is static, should be set only once.
|
||||||
if ((UseParNewGC ||
|
if ((UseParNewGC ||
|
||||||
(UseConcMarkSweepGC && CMSParallelRemarkEnabled) ||
|
(UseConcMarkSweepGC && (CMSParallelInitialMarkEnabled ||
|
||||||
|
CMSParallelRemarkEnabled)) ||
|
||||||
UseG1GC) &&
|
UseG1GC) &&
|
||||||
ParallelGCThreads > 0) {
|
ParallelGCThreads > 0) {
|
||||||
_workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads,
|
_workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads,
|
||||||
|
|
|
@ -60,6 +60,28 @@
|
||||||
#define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
|
#define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
|
||||||
#define DEFAULT_JAVA_LAUNCHER "generic"
|
#define DEFAULT_JAVA_LAUNCHER "generic"
|
||||||
|
|
||||||
|
// Disable options not supported in this release, with a warning if they
|
||||||
|
// were explicitly requested on the command-line
|
||||||
|
#define UNSUPPORTED_OPTION(opt, description) \
|
||||||
|
do { \
|
||||||
|
if (opt) { \
|
||||||
|
if (FLAG_IS_CMDLINE(opt)) { \
|
||||||
|
warning(description " is disabled in this release."); \
|
||||||
|
} \
|
||||||
|
FLAG_SET_DEFAULT(opt, false); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define UNSUPPORTED_GC_OPTION(gc) \
|
||||||
|
do { \
|
||||||
|
if (gc) { \
|
||||||
|
if (FLAG_IS_CMDLINE(gc)) { \
|
||||||
|
warning(#gc " is not supported in this VM. Using Serial GC."); \
|
||||||
|
} \
|
||||||
|
FLAG_SET_DEFAULT(gc, false); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
char** Arguments::_jvm_flags_array = NULL;
|
char** Arguments::_jvm_flags_array = NULL;
|
||||||
int Arguments::_num_jvm_flags = 0;
|
int Arguments::_num_jvm_flags = 0;
|
||||||
char** Arguments::_jvm_args_array = NULL;
|
char** Arguments::_jvm_args_array = NULL;
|
||||||
|
@ -1891,6 +1913,10 @@ void Arguments::check_deprecated_gc_flags() {
|
||||||
warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
|
warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
|
||||||
"and will likely be removed in future release");
|
"and will likely be removed in future release");
|
||||||
}
|
}
|
||||||
|
if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
|
||||||
|
warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
|
||||||
|
"Use MaxRAMFraction instead.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check stack pages settings
|
// Check stack pages settings
|
||||||
|
@ -3124,14 +3150,17 @@ jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_req
|
||||||
FLAG_SET_DEFAULT(UseLargePages, false);
|
FLAG_SET_DEFAULT(UseLargePages, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tiered compilation is undefined with C1.
|
|
||||||
TieredCompilation = false;
|
|
||||||
#else
|
#else
|
||||||
if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
|
if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
|
||||||
FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
|
FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TIERED
|
||||||
|
// Tiered compilation is undefined.
|
||||||
|
UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
|
||||||
|
#endif
|
||||||
|
|
||||||
// If we are running in a headless jre, force java.awt.headless property
|
// If we are running in a headless jre, force java.awt.headless property
|
||||||
// to be true unless the property has already been set.
|
// to be true unless the property has already been set.
|
||||||
// Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
|
// Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
|
||||||
|
@ -3274,29 +3303,6 @@ void Arguments::set_shared_spaces_flags() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable options not supported in this release, with a warning if they
|
|
||||||
// were explicitly requested on the command-line
|
|
||||||
#define UNSUPPORTED_OPTION(opt, description) \
|
|
||||||
do { \
|
|
||||||
if (opt) { \
|
|
||||||
if (FLAG_IS_CMDLINE(opt)) { \
|
|
||||||
warning(description " is disabled in this release."); \
|
|
||||||
} \
|
|
||||||
FLAG_SET_DEFAULT(opt, false); \
|
|
||||||
} \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
|
|
||||||
#define UNSUPPORTED_GC_OPTION(gc) \
|
|
||||||
do { \
|
|
||||||
if (gc) { \
|
|
||||||
if (FLAG_IS_CMDLINE(gc)) { \
|
|
||||||
warning(#gc " is not supported in this VM. Using Serial GC."); \
|
|
||||||
} \
|
|
||||||
FLAG_SET_DEFAULT(gc, false); \
|
|
||||||
} \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#if !INCLUDE_ALL_GCS
|
#if !INCLUDE_ALL_GCS
|
||||||
static void force_serial_gc() {
|
static void force_serial_gc() {
|
||||||
FLAG_SET_DEFAULT(UseSerialGC, true);
|
FLAG_SET_DEFAULT(UseSerialGC, true);
|
||||||
|
|
|
@ -1688,6 +1688,9 @@ class CommandLineFlags {
|
||||||
product(bool, CMSAbortSemantics, false, \
|
product(bool, CMSAbortSemantics, false, \
|
||||||
"Whether abort-on-overflow semantics is implemented") \
|
"Whether abort-on-overflow semantics is implemented") \
|
||||||
\
|
\
|
||||||
|
product(bool, CMSParallelInitialMarkEnabled, true, \
|
||||||
|
"Use the parallel initial mark.") \
|
||||||
|
\
|
||||||
product(bool, CMSParallelRemarkEnabled, true, \
|
product(bool, CMSParallelRemarkEnabled, true, \
|
||||||
"Whether parallel remark enabled (only if ParNewGC)") \
|
"Whether parallel remark enabled (only if ParNewGC)") \
|
||||||
\
|
\
|
||||||
|
@ -1699,6 +1702,14 @@ class CommandLineFlags {
|
||||||
"Whether to always record survivor space PLAB bdries" \
|
"Whether to always record survivor space PLAB bdries" \
|
||||||
" (effective only if CMSParallelSurvivorRemarkEnabled)") \
|
" (effective only if CMSParallelSurvivorRemarkEnabled)") \
|
||||||
\
|
\
|
||||||
|
product(bool, CMSEdenChunksRecordAlways, true, \
|
||||||
|
"Whether to always record eden chunks used for " \
|
||||||
|
"the parallel initial mark or remark of eden" ) \
|
||||||
|
\
|
||||||
|
product(bool, CMSPrintEdenSurvivorChunks, false, \
|
||||||
|
"Print the eden and the survivor chunks used for the parallel " \
|
||||||
|
"initial mark or remark of the eden/survivor spaces") \
|
||||||
|
\
|
||||||
product(bool, CMSConcurrentMTEnabled, true, \
|
product(bool, CMSConcurrentMTEnabled, true, \
|
||||||
"Whether multi-threaded concurrent work enabled (if ParNewGC)") \
|
"Whether multi-threaded concurrent work enabled (if ParNewGC)") \
|
||||||
\
|
\
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -211,9 +211,9 @@ void GCNotifier::sendNotificationInternal(TRAPS) {
|
||||||
NotificationMark nm(request);
|
NotificationMark nm(request);
|
||||||
Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);
|
Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);
|
||||||
|
|
||||||
Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
|
Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK);
|
||||||
Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
|
Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);
|
||||||
Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
|
Handle objCause = java_lang_String::create_from_str(request->gcCause, CHECK);
|
||||||
|
|
||||||
Klass* k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
|
Klass* k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
|
||||||
instanceKlassHandle gc_mbean_klass(THREAD, k);
|
instanceKlassHandle gc_mbean_klass(THREAD, k);
|
||||||
|
|
|
@ -1831,13 +1831,13 @@ class ThreadTimesClosure: public ThreadClosure {
|
||||||
private:
|
private:
|
||||||
objArrayHandle _names_strings;
|
objArrayHandle _names_strings;
|
||||||
char **_names_chars;
|
char **_names_chars;
|
||||||
typeArrayOop _times;
|
typeArrayHandle _times;
|
||||||
int _names_len;
|
int _names_len;
|
||||||
int _times_len;
|
int _times_len;
|
||||||
int _count;
|
int _count;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThreadTimesClosure(objArrayHandle names, typeArrayOop times);
|
ThreadTimesClosure(objArrayHandle names, typeArrayHandle times);
|
||||||
~ThreadTimesClosure();
|
~ThreadTimesClosure();
|
||||||
virtual void do_thread(Thread* thread);
|
virtual void do_thread(Thread* thread);
|
||||||
void do_unlocked();
|
void do_unlocked();
|
||||||
|
@ -1845,9 +1845,9 @@ class ThreadTimesClosure: public ThreadClosure {
|
||||||
};
|
};
|
||||||
|
|
||||||
ThreadTimesClosure::ThreadTimesClosure(objArrayHandle names,
|
ThreadTimesClosure::ThreadTimesClosure(objArrayHandle names,
|
||||||
typeArrayOop times) {
|
typeArrayHandle times) {
|
||||||
assert(names() != NULL, "names was NULL");
|
assert(names() != NULL, "names was NULL");
|
||||||
assert(times != NULL, "times was NULL");
|
assert(times() != NULL, "times was NULL");
|
||||||
_names_strings = names;
|
_names_strings = names;
|
||||||
_names_len = names->length();
|
_names_len = names->length();
|
||||||
_names_chars = NEW_C_HEAP_ARRAY(char*, _names_len, mtInternal);
|
_names_chars = NEW_C_HEAP_ARRAY(char*, _names_len, mtInternal);
|
||||||
|
@ -1925,7 +1925,7 @@ JVM_ENTRY(jint, jmm_GetInternalThreadTimes(JNIEnv *env,
|
||||||
typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(times));
|
typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(times));
|
||||||
typeArrayHandle times_ah(THREAD, ta);
|
typeArrayHandle times_ah(THREAD, ta);
|
||||||
|
|
||||||
ThreadTimesClosure ttc(names_ah, times_ah());
|
ThreadTimesClosure ttc(names_ah, times_ah);
|
||||||
{
|
{
|
||||||
MutexLockerEx ml(Threads_lock);
|
MutexLockerEx ml(Threads_lock);
|
||||||
Threads::threads_do(&ttc);
|
Threads::threads_do(&ttc);
|
||||||
|
|
|
@ -125,13 +125,13 @@ void Exceptions::_throw_oop(Thread* thread, const char* file, int line, oop exce
|
||||||
}
|
}
|
||||||
|
|
||||||
void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) {
|
void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) {
|
||||||
|
ResourceMark rm;
|
||||||
assert(h_exception() != NULL, "exception should not be NULL");
|
assert(h_exception() != NULL, "exception should not be NULL");
|
||||||
|
|
||||||
// tracing (do this up front - so it works during boot strapping)
|
// tracing (do this up front - so it works during boot strapping)
|
||||||
if (TraceExceptions) {
|
if (TraceExceptions) {
|
||||||
ttyLocker ttyl;
|
ttyLocker ttyl;
|
||||||
ResourceMark rm;
|
tty->print_cr("Exception <%s%s%s> (" INTPTR_FORMAT ") \n"
|
||||||
tty->print_cr("Exception <%s>%s%s (" INTPTR_FORMAT " ) \n"
|
|
||||||
"thrown [%s, line %d]\nfor thread " INTPTR_FORMAT,
|
"thrown [%s, line %d]\nfor thread " INTPTR_FORMAT,
|
||||||
h_exception->print_value_string(),
|
h_exception->print_value_string(),
|
||||||
message ? ": " : "", message ? message : "",
|
message ? ": " : "", message ? message : "",
|
||||||
|
@ -141,7 +141,9 @@ void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exc
|
||||||
NOT_PRODUCT(Exceptions::debug_check_abort(h_exception, message));
|
NOT_PRODUCT(Exceptions::debug_check_abort(h_exception, message));
|
||||||
|
|
||||||
// Check for special boot-strapping/vm-thread handling
|
// Check for special boot-strapping/vm-thread handling
|
||||||
if (special_exception(thread, file, line, h_exception)) return;
|
if (special_exception(thread, file, line, h_exception)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert(h_exception->is_a(SystemDictionary::Throwable_klass()), "exception is not a subclass of java/lang/Throwable");
|
assert(h_exception->is_a(SystemDictionary::Throwable_klass()), "exception is not a subclass of java/lang/Throwable");
|
||||||
|
|
||||||
|
@ -149,7 +151,9 @@ void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exc
|
||||||
thread->set_pending_exception(h_exception(), file, line);
|
thread->set_pending_exception(h_exception(), file, line);
|
||||||
|
|
||||||
// vm log
|
// vm log
|
||||||
Events::log_exception(thread, "Threw " INTPTR_FORMAT " at %s:%d", (address)h_exception(), file, line);
|
Events::log_exception(thread, "Exception <%s%s%s> (" INTPTR_FORMAT ") thrown at [%s, line %d]",
|
||||||
|
h_exception->print_value_string(), message ? ": " : "", message ? message : "",
|
||||||
|
(address)h_exception(), file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,13 @@ bool GenericTaskQueue<E, F, N>::pop_local_slow(uint localBot, Age oldAge) {
|
||||||
template<class E, MEMFLAGS F, unsigned int N>
|
template<class E, MEMFLAGS F, unsigned int N>
|
||||||
bool GenericTaskQueue<E, F, N>::pop_global(E& t) {
|
bool GenericTaskQueue<E, F, N>::pop_global(E& t) {
|
||||||
Age oldAge = _age.get();
|
Age oldAge = _age.get();
|
||||||
uint localBot = _bottom;
|
// Architectures with weak memory model require a barrier here
|
||||||
|
// to guarantee that bottom is not older than age,
|
||||||
|
// which is crucial for the correctness of the algorithm.
|
||||||
|
#if !(defined SPARC || defined IA32 || defined AMD64)
|
||||||
|
OrderAccess::fence();
|
||||||
|
#endif
|
||||||
|
uint localBot = OrderAccess::load_acquire((volatile juint*)&_bottom);
|
||||||
uint n_elems = size(localBot, oldAge.top());
|
uint n_elems = size(localBot, oldAge.top());
|
||||||
if (n_elems == 0) {
|
if (n_elems == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -644,7 +650,7 @@ public:
|
||||||
template<class E, MEMFLAGS F, unsigned int N> inline bool
|
template<class E, MEMFLAGS F, unsigned int N> inline bool
|
||||||
GenericTaskQueue<E, F, N>::push(E t) {
|
GenericTaskQueue<E, F, N>::push(E t) {
|
||||||
uint localBot = _bottom;
|
uint localBot = _bottom;
|
||||||
assert((localBot >= 0) && (localBot < N), "_bottom out of range.");
|
assert(localBot < N, "_bottom out of range.");
|
||||||
idx_t top = _age.top();
|
idx_t top = _age.top();
|
||||||
uint dirty_n_elems = dirty_size(localBot, top);
|
uint dirty_n_elems = dirty_size(localBot, top);
|
||||||
assert(dirty_n_elems < N, "n_elems out of range.");
|
assert(dirty_n_elems < N, "n_elems out of range.");
|
||||||
|
|
|
@ -35,10 +35,6 @@ public class CheckUpperLimit {
|
||||||
ProcessBuilder pb;
|
ProcessBuilder pb;
|
||||||
OutputAnalyzer out;
|
OutputAnalyzer out;
|
||||||
|
|
||||||
pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=2048m", "-version");
|
|
||||||
out = new OutputAnalyzer(pb.start());
|
|
||||||
out.shouldHaveExitValue(0);
|
|
||||||
|
|
||||||
pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=2049m", "-version");
|
pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=2049m", "-version");
|
||||||
out = new OutputAnalyzer(pb.start());
|
out = new OutputAnalyzer(pb.start());
|
||||||
out.shouldContain("Invalid ReservedCodeCacheSize=");
|
out.shouldContain("Invalid ReservedCodeCacheSize=");
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8016474
|
||||||
|
* @summary The bug only happens with C1 and G1 using a different ObjectAlignmentInBytes than KlassAlignmentInBytes (which is 8)
|
||||||
|
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 GetUnsafeObjectG1PreBarrier
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import sun.misc.Unsafe;
|
||||||
|
|
||||||
|
public class GetUnsafeObjectG1PreBarrier {
|
||||||
|
private static final Unsafe unsafe;
|
||||||
|
private static final int N = 100_000;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||||
|
theUnsafe.setAccessible(true);
|
||||||
|
unsafe = (Unsafe) theUnsafe.get(null);
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object a;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Throwable {
|
||||||
|
new GetUnsafeObjectG1PreBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetUnsafeObjectG1PreBarrier() throws Throwable {
|
||||||
|
doit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doit() throws Throwable {
|
||||||
|
Field field = GetUnsafeObjectG1PreBarrier.class.getField("a");
|
||||||
|
long fieldOffset = unsafe.objectFieldOffset(field);
|
||||||
|
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
readField(this, fieldOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readField(Object o, long fieldOffset) {
|
||||||
|
unsafe.getObject(o, fieldOffset);
|
||||||
|
}
|
||||||
|
}
|
64
hotspot/test/gc/arguments/TestG1HeapRegionSize.java
Normal file
64
hotspot/test/gc/arguments/TestG1HeapRegionSize.java
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test TestG1HeapRegionSize
|
||||||
|
* @key gc
|
||||||
|
* @bug 8021879
|
||||||
|
* @summary Verify that the flag G1HeapRegionSize is updated properly
|
||||||
|
* @run main/othervm -Xmx64m TestG1HeapRegionSize 1048576
|
||||||
|
* @run main/othervm -XX:G1HeapRegionSize=2m -Xmx64m TestG1HeapRegionSize 2097152
|
||||||
|
* @run main/othervm -XX:G1HeapRegionSize=3m -Xmx64m TestG1HeapRegionSize 2097152
|
||||||
|
* @run main/othervm -XX:G1HeapRegionSize=64m -Xmx256m TestG1HeapRegionSize 33554432
|
||||||
|
*/
|
||||||
|
|
||||||
|
import sun.management.ManagementFactoryHelper;
|
||||||
|
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||||
|
import com.sun.management.VMOption;
|
||||||
|
|
||||||
|
public class TestG1HeapRegionSize {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
|
||||||
|
|
||||||
|
VMOption option = diagnostic.getVMOption("UseG1GC");
|
||||||
|
if (option.getValue().equals("false")) {
|
||||||
|
System.out.println("Skipping this test. It is only a G1 test.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String expectedValue = getExpectedValue(args);
|
||||||
|
option = diagnostic.getVMOption("G1HeapRegionSize");
|
||||||
|
if (!expectedValue.equals(option.getValue())) {
|
||||||
|
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + option.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getExpectedValue(String[] args) {
|
||||||
|
if (args.length != 1) {
|
||||||
|
throw new RuntimeException("Wrong number of arguments. Expected 1 but got " + args.length);
|
||||||
|
}
|
||||||
|
return args[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,7 +27,7 @@
|
||||||
* @bug 8014240
|
* @bug 8014240
|
||||||
* @summary Test output of G1PrintRegionRememberedSetInfo
|
* @summary Test output of G1PrintRegionRememberedSetInfo
|
||||||
* @library /testlibrary
|
* @library /testlibrary
|
||||||
* @build TestPrintRegionRememberedSetInfo
|
* @run main TestPrintRegionRememberedSetInfo
|
||||||
* @author thomas.schatzl@oracle.com
|
* @author thomas.schatzl@oracle.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test TestDefaultMaxRAMFraction
|
||||||
|
* @key gc
|
||||||
|
* @bug 8021967
|
||||||
|
* @summary Test that the deprecated TestDefaultMaxRAMFraction flag print a warning message
|
||||||
|
* @library /testlibrary
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.oracle.java.testlibrary.OutputAnalyzer;
|
||||||
|
import com.oracle.java.testlibrary.ProcessTools;
|
||||||
|
|
||||||
|
public class TestDefaultMaxRAMFraction {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:DefaultMaxRAMFraction=4", "-version");
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldContain("warning: DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. Use MaxRAMFraction instead.");
|
||||||
|
output.shouldNotContain("error");
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
##
|
##
|
||||||
## @test Test6929067.sh
|
## @test Test6929067.sh
|
||||||
## @bug 6929067
|
## @bug 6929067
|
||||||
|
## @bug 8021296
|
||||||
## @summary Stack guard pages should be removed when thread is detached
|
## @summary Stack guard pages should be removed when thread is detached
|
||||||
## @compile T.java
|
## @compile T.java
|
||||||
## @run shell Test6929067.sh
|
## @run shell Test6929067.sh
|
||||||
|
@ -21,6 +22,11 @@ echo "TESTSRC=${TESTSRC}"
|
||||||
OS=`uname -s`
|
OS=`uname -s`
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
Linux)
|
Linux)
|
||||||
|
gcc_cmd=`which gcc`
|
||||||
|
if [ "x$gcc_cmd" == "x" ]; then
|
||||||
|
echo "WARNING: gcc not found. Cannot execute test." 2>&1
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
NULL=/dev/null
|
NULL=/dev/null
|
||||||
PS=":"
|
PS=":"
|
||||||
FS="/"
|
FS="/"
|
||||||
|
@ -119,10 +125,10 @@ echo "VM type: ${VMTYPE}"
|
||||||
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
|
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
|
||||||
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
|
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
|
||||||
|
|
||||||
gcc -DLINUX ${COMP_FLAG} -o invoke \
|
$gcc_cmd -DLINUX ${COMP_FLAG} -o invoke \
|
||||||
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
|
-I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
|
||||||
-L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \
|
-L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \
|
||||||
-ljvm -lpthread invoke.c
|
-ljvm -lpthread invoke.c
|
||||||
|
|
||||||
./invoke
|
./invoke
|
||||||
exit $?
|
exit $?
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
##
|
##
|
||||||
## @test Test7107135.sh
|
## @test Test7107135.sh
|
||||||
## @bug 7107135
|
## @bug 7107135
|
||||||
|
## @bug 8021296
|
||||||
## @summary Stack guard pages lost after loading library with executable stack.
|
## @summary Stack guard pages lost after loading library with executable stack.
|
||||||
## @run shell Test7107135.sh
|
## @run shell Test7107135.sh
|
||||||
##
|
##
|
||||||
|
@ -45,6 +46,11 @@ OS=`uname -s`
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
Linux)
|
Linux)
|
||||||
echo "Testing on Linux"
|
echo "Testing on Linux"
|
||||||
|
gcc_cmd=`which gcc`
|
||||||
|
if [ "x$gcc_cmd" == "x" ]; then
|
||||||
|
echo "WARNING: gcc not found. Cannot execute test." 2>&1
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
NULL=NUL
|
NULL=NUL
|
||||||
|
@ -62,7 +68,10 @@ THIS_DIR=.
|
||||||
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
|
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
|
||||||
${TESTJAVA}${FS}bin${FS}javac *.java
|
${TESTJAVA}${FS}bin${FS}javac *.java
|
||||||
|
|
||||||
gcc -fPIC -shared -c -o test.o -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux ${TESTSRC}${FS}test.c
|
$gcc_cmd -fPIC -shared -c -o test.o \
|
||||||
|
-I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
|
||||||
|
${TESTSRC}${FS}test.c
|
||||||
|
|
||||||
ld -shared -z execstack -o libtest-rwx.so test.o
|
ld -shared -z execstack -o libtest-rwx.so test.o
|
||||||
ld -shared -z noexecstack -o libtest-rw.so test.o
|
ld -shared -z noexecstack -o libtest-rw.so test.o
|
||||||
|
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
# or visit www.oracle.com if you need additional information or have any
|
|
||||||
# questions.
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
# @test Test8000968.sh
|
|
||||||
# @bug 8000968
|
|
||||||
# @summary NPG: UseCompressedKlassPointers asserts with ObjectAlignmentInBytes=32
|
|
||||||
# @run shell Test8000968.sh
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ "${TESTJAVA}" = "" ]
|
|
||||||
then
|
|
||||||
PARENT=`dirname \`which java\``
|
|
||||||
TESTJAVA=`dirname ${PARENT}`
|
|
||||||
printf "TESTJAVA not set, selecting " ${TESTJAVA}
|
|
||||||
printf " If this is incorrect, try setting the variable manually.\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# set platform-dependent variables
|
|
||||||
OS=`uname -s`
|
|
||||||
case "$OS" in
|
|
||||||
Windows_* )
|
|
||||||
FS="\\"
|
|
||||||
NULL=NUL
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
FS="/"
|
|
||||||
NULL=/dev/null
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
JAVA=${TESTJAVA}${FS}bin${FS}java
|
|
||||||
|
|
||||||
#
|
|
||||||
# See if platform has 64 bit java.
|
|
||||||
#
|
|
||||||
${JAVA} ${TESTVMOPTS} -d64 -version 2>&1 | grep -i "does not support" > ${NULL}
|
|
||||||
if [ "$?" != "1" ]
|
|
||||||
then
|
|
||||||
printf "Platform is 32 bit, does not support -XX:ObjectAlignmentInBytes= option.\n"
|
|
||||||
printf "Passed.\n"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Test -XX:ObjectAlignmentInBytes with -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops.
|
|
||||||
#
|
|
||||||
${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=16 -version 2>&1 > ${NULL}
|
|
||||||
if [ "$?" != "0" ]
|
|
||||||
then
|
|
||||||
printf "FAILED: -XX:ObjectAlignmentInBytes=16 option did not work.\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=32 -version 2>&1 > ${NULL}
|
|
||||||
if [ "$?" != "0" ]
|
|
||||||
then
|
|
||||||
printf "FAILED: -XX:ObjectAlignmentInBytes=32 option did not work.\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=64 -version 2>&1 > ${NULL}
|
|
||||||
if [ "$?" != "0" ]
|
|
||||||
then
|
|
||||||
printf "FAILED: -XX:ObjectAlignmentInBytes=64 option did not work.\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
${JAVA} ${TESTVMOPTS} -d64 -XX:+UseCompressedKlassPointers -XX:+UseCompressedOops -XX:ObjectAlignmentInBytes=128 -version 2>&1 > ${NULL}
|
|
||||||
if [ "$?" != "0" ]
|
|
||||||
then
|
|
||||||
printf "FAILED: -XX:ObjectAlignmentInBytes=128 option did not work.\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
printf "Passed.\n"
|
|
||||||
exit 0
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8000968
|
||||||
|
* @key regression
|
||||||
|
* @summary NPG: UseCompressedKlassPointers asserts with ObjectAlignmentInBytes=32
|
||||||
|
* @library /testlibrary
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.oracle.java.testlibrary.*;
|
||||||
|
|
||||||
|
public class CompressedKlassPointerAndOops {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
if (!Platform.is64bit()) {
|
||||||
|
// Can't test this on 32 bit, just pass
|
||||||
|
System.out.println("Skipping test on 32bit");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
runWithAlignment(16);
|
||||||
|
runWithAlignment(32);
|
||||||
|
runWithAlignment(64);
|
||||||
|
runWithAlignment(128);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void runWithAlignment(int alignment) throws Exception {
|
||||||
|
ProcessBuilder pb;
|
||||||
|
OutputAnalyzer output;
|
||||||
|
|
||||||
|
pb = ProcessTools.createJavaProcessBuilder(
|
||||||
|
"-XX:+UseCompressedKlassPointers",
|
||||||
|
"-XX:+UseCompressedOops",
|
||||||
|
"-XX:ObjectAlignmentInBytes=" + alignment,
|
||||||
|
"-version");
|
||||||
|
|
||||||
|
output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -25,8 +25,9 @@
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 7196045
|
* @bug 7196045
|
||||||
|
* @bug 8014294
|
||||||
* @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
|
* @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
|
||||||
* @run main/othervm -XX:+UsePerfData Test7196045
|
* @run main/othervm -XX:+UsePerfData -Xmx32m ThreadCpuTimesDeadlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
@ -35,9 +36,10 @@ import javax.management.MBeanServer;
|
||||||
import javax.management.MalformedObjectNameException;
|
import javax.management.MalformedObjectNameException;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
|
|
||||||
public class Test7196045 {
|
public class ThreadCpuTimesDeadlock {
|
||||||
|
|
||||||
public static long duration = 1000 * 60 * 2;
|
public static byte[] dummy;
|
||||||
|
public static long duration = 10 * 1000;
|
||||||
private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal";
|
private static final String HOTSPOT_INTERNAL = "sun.management:type=HotspotInternal";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -57,6 +59,18 @@ public class Test7196045 {
|
||||||
throw new RuntimeException("Bad object name" + e1);
|
throw new RuntimeException("Bad object name" + e1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Thread that allocs memory to generate GC's
|
||||||
|
Thread allocThread = new Thread() {
|
||||||
|
public void run() {
|
||||||
|
while (true) {
|
||||||
|
dummy = new byte[4096];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
allocThread.setDaemon(true);
|
||||||
|
allocThread.start();
|
||||||
|
|
||||||
long endTime = System.currentTimeMillis() + duration;
|
long endTime = System.currentTimeMillis() + duration;
|
||||||
long i = 0;
|
long i = 0;
|
||||||
while (true) {
|
while (true) {
|
|
@ -27,6 +27,7 @@
|
||||||
## @test Test8017498.sh
|
## @test Test8017498.sh
|
||||||
## @bug 8017498
|
## @bug 8017498
|
||||||
## @bug 8020791
|
## @bug 8020791
|
||||||
|
## @bug 8021296
|
||||||
## @summary sigaction(sig) results in process hang/timed-out if sig is much greater than SIGRTMAX
|
## @summary sigaction(sig) results in process hang/timed-out if sig is much greater than SIGRTMAX
|
||||||
## @run shell/timeout=30 Test8017498.sh
|
## @run shell/timeout=30 Test8017498.sh
|
||||||
##
|
##
|
||||||
|
@ -45,6 +46,11 @@ OS=`uname -s`
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
Linux)
|
Linux)
|
||||||
echo "Testing on Linux"
|
echo "Testing on Linux"
|
||||||
|
gcc_cmd=`which gcc`
|
||||||
|
if [ "x$gcc_cmd" == "x" ]; then
|
||||||
|
echo "WARNING: gcc not found. Cannot execute test." 2>&1
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
if [ "$VM_BITS" = "64" ]
|
if [ "$VM_BITS" = "64" ]
|
||||||
then
|
then
|
||||||
MY_LD_PRELOAD=${TESTJAVA}${FS}jre${FS}lib${FS}amd64${FS}libjsig.so
|
MY_LD_PRELOAD=${TESTJAVA}${FS}jre${FS}lib${FS}amd64${FS}libjsig.so
|
||||||
|
@ -64,15 +70,11 @@ THIS_DIR=.
|
||||||
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
|
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
|
||||||
${TESTJAVA}${FS}bin${FS}javac *.java
|
${TESTJAVA}${FS}bin${FS}javac *.java
|
||||||
|
|
||||||
gcc -DLINUX -fPIC -shared \
|
$gcc_cmd -DLINUX -fPIC -shared \
|
||||||
-o ${TESTSRC}${FS}libTestJNI.so \
|
-o ${TESTSRC}${FS}libTestJNI.so \
|
||||||
-I${TESTJAVA}${FS}include \
|
-I${TESTJAVA}${FS}include \
|
||||||
-I${TESTJAVA}${FS}include${FS}linux \
|
-I${TESTJAVA}${FS}include${FS}linux \
|
||||||
${TESTSRC}${FS}TestJNI.c
|
${TESTSRC}${FS}TestJNI.c
|
||||||
if [ $? != 0 ]
|
|
||||||
then
|
|
||||||
echo "WARNING: the gcc command failed." 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# run the java test in the background
|
# run the java test in the background
|
||||||
cmd="LD_PRELOAD=$MY_LD_PRELOAD \
|
cmd="LD_PRELOAD=$MY_LD_PRELOAD \
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE // for the definition of REG_RIP in ucontext.h
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
@ -32,11 +31,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sig_handler(int sig, siginfo_t *info, ucontext_t *context) {
|
void sig_handler(int sig, siginfo_t *info, ucontext_t *context) {
|
||||||
int thrNum;
|
|
||||||
|
|
||||||
printf( " HANDLER (1) " );
|
printf( " HANDLER (1) " );
|
||||||
// Move forward RIP to skip failing instruction
|
|
||||||
context->uc_mcontext.gregs[REG_RIP] += 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_TestJNI_doSomething(JNIEnv *env, jclass klass, jint val) {
|
JNIEXPORT void JNICALL Java_TestJNI_doSomething(JNIEnv *env, jclass klass, jint val) {
|
||||||
|
|
124
hotspot/test/testlibrary/OutputAnalyzerReportingTest.java
Normal file
124
hotspot/test/testlibrary/OutputAnalyzerReportingTest.java
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @summary Test the OutputAnalyzer reporting functionality,
|
||||||
|
* such as printing additional diagnostic info
|
||||||
|
* (exit code, stdout, stderr, command line, etc.)
|
||||||
|
* @library /testlibrary
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import com.oracle.java.testlibrary.OutputAnalyzer;
|
||||||
|
import com.oracle.java.testlibrary.ProcessTools;
|
||||||
|
|
||||||
|
|
||||||
|
public class OutputAnalyzerReportingTest {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// Create the output analyzer under test
|
||||||
|
String stdout = "aaaaaa";
|
||||||
|
String stderr = "bbbbbb";
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(stdout, stderr);
|
||||||
|
|
||||||
|
// Expected summary values should be the same for all cases,
|
||||||
|
// since the outputAnalyzer object is the same
|
||||||
|
String expectedExitValue = "-1";
|
||||||
|
String expectedSummary =
|
||||||
|
" stdout: [" + stdout + "];\n" +
|
||||||
|
" stderr: [" + stderr + "]\n" +
|
||||||
|
" exitValue = " + expectedExitValue + "\n";
|
||||||
|
|
||||||
|
|
||||||
|
DiagnosticSummaryTestRunner testRunner =
|
||||||
|
new DiagnosticSummaryTestRunner();
|
||||||
|
|
||||||
|
// should have exit value
|
||||||
|
testRunner.init(expectedSummary);
|
||||||
|
int unexpectedExitValue = 2;
|
||||||
|
try {
|
||||||
|
output.shouldHaveExitValue(unexpectedExitValue);
|
||||||
|
} catch (RuntimeException e) { }
|
||||||
|
testRunner.closeAndCheckResults();
|
||||||
|
|
||||||
|
// should not contain
|
||||||
|
testRunner.init(expectedSummary);
|
||||||
|
try {
|
||||||
|
output.shouldNotContain(stdout);
|
||||||
|
} catch (RuntimeException e) { }
|
||||||
|
testRunner.closeAndCheckResults();
|
||||||
|
|
||||||
|
// should contain
|
||||||
|
testRunner.init(expectedSummary);
|
||||||
|
try {
|
||||||
|
output.shouldContain("unexpected-stuff");
|
||||||
|
} catch (RuntimeException e) { }
|
||||||
|
testRunner.closeAndCheckResults();
|
||||||
|
|
||||||
|
// should not match
|
||||||
|
testRunner.init(expectedSummary);
|
||||||
|
try {
|
||||||
|
output.shouldNotMatch("[a]");
|
||||||
|
} catch (RuntimeException e) { }
|
||||||
|
testRunner.closeAndCheckResults();
|
||||||
|
|
||||||
|
// should match
|
||||||
|
testRunner.init(expectedSummary);
|
||||||
|
try {
|
||||||
|
output.shouldMatch("[qwerty]");
|
||||||
|
} catch (RuntimeException e) { }
|
||||||
|
testRunner.closeAndCheckResults();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class DiagnosticSummaryTestRunner {
|
||||||
|
private ByteArrayOutputStream byteStream =
|
||||||
|
new ByteArrayOutputStream(10000);
|
||||||
|
|
||||||
|
private String expectedSummary = "";
|
||||||
|
private PrintStream errStream;
|
||||||
|
|
||||||
|
|
||||||
|
public void init(String expectedSummary) {
|
||||||
|
this.expectedSummary = expectedSummary;
|
||||||
|
byteStream.reset();
|
||||||
|
errStream = new PrintStream(byteStream);
|
||||||
|
System.setErr(errStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeAndCheckResults() {
|
||||||
|
// check results
|
||||||
|
errStream.close();
|
||||||
|
String stdErrStr = byteStream.toString();
|
||||||
|
if (!stdErrStr.contains(expectedSummary)) {
|
||||||
|
throw new RuntimeException("The output does not contain "
|
||||||
|
+ "the diagnostic message, or the message is incorrect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -76,7 +76,8 @@ public final class OutputAnalyzer {
|
||||||
*/
|
*/
|
||||||
public void shouldContain(String expectedString) {
|
public void shouldContain(String expectedString) {
|
||||||
if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) {
|
if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) {
|
||||||
throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr: [" + stdout + stderr + "]\n");
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,8 @@ public final class OutputAnalyzer {
|
||||||
*/
|
*/
|
||||||
public void stdoutShouldContain(String expectedString) {
|
public void stdoutShouldContain(String expectedString) {
|
||||||
if (!stdout.contains(expectedString)) {
|
if (!stdout.contains(expectedString)) {
|
||||||
throw new RuntimeException("'" + expectedString + "' missing from stdout: [" + stdout + "]\n");
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("'" + expectedString + "' missing from stdout \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +102,8 @@ public final class OutputAnalyzer {
|
||||||
*/
|
*/
|
||||||
public void stderrShouldContain(String expectedString) {
|
public void stderrShouldContain(String expectedString) {
|
||||||
if (!stderr.contains(expectedString)) {
|
if (!stderr.contains(expectedString)) {
|
||||||
throw new RuntimeException("'" + expectedString + "' missing from stderr: [" + stderr + "]\n");
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("'" + expectedString + "' missing from stderr \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,10 +115,12 @@ public final class OutputAnalyzer {
|
||||||
*/
|
*/
|
||||||
public void shouldNotContain(String notExpectedString) {
|
public void shouldNotContain(String notExpectedString) {
|
||||||
if (stdout.contains(notExpectedString)) {
|
if (stdout.contains(notExpectedString)) {
|
||||||
throw new RuntimeException("'" + notExpectedString + "' found in stdout: [" + stdout + "]\n");
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
|
||||||
}
|
}
|
||||||
if (stderr.contains(notExpectedString)) {
|
if (stderr.contains(notExpectedString)) {
|
||||||
throw new RuntimeException("'" + notExpectedString + "' found in stderr: [" + stderr + "]\n");
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +132,8 @@ public final class OutputAnalyzer {
|
||||||
*/
|
*/
|
||||||
public void stdoutShouldNotContain(String notExpectedString) {
|
public void stdoutShouldNotContain(String notExpectedString) {
|
||||||
if (stdout.contains(notExpectedString)) {
|
if (stdout.contains(notExpectedString)) {
|
||||||
throw new RuntimeException("'" + notExpectedString + "' found in stdout: [" + stdout + "]\n");
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("'" + notExpectedString + "' found in stdout \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +145,8 @@ public final class OutputAnalyzer {
|
||||||
*/
|
*/
|
||||||
public void stderrShouldNotContain(String notExpectedString) {
|
public void stderrShouldNotContain(String notExpectedString) {
|
||||||
if (stderr.contains(notExpectedString)) {
|
if (stderr.contains(notExpectedString)) {
|
||||||
throw new RuntimeException("'" + notExpectedString + "' found in stderr: [" + stderr + "]\n");
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("'" + notExpectedString + "' found in stderr \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,9 +161,9 @@ public final class OutputAnalyzer {
|
||||||
Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
||||||
Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
||||||
if (!stdoutMatcher.find() && !stderrMatcher.find()) {
|
if (!stdoutMatcher.find() && !stderrMatcher.find()) {
|
||||||
|
reportDiagnosticSummary();
|
||||||
throw new RuntimeException("'" + pattern
|
throw new RuntimeException("'" + pattern
|
||||||
+ "' missing from stdout/stderr: [" + stdout + stderr
|
+ "' missing from stdout/stderr \n");
|
||||||
+ "]\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,8 +177,9 @@ public final class OutputAnalyzer {
|
||||||
public void stdoutShouldMatch(String pattern) {
|
public void stdoutShouldMatch(String pattern) {
|
||||||
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
||||||
if (!matcher.find()) {
|
if (!matcher.find()) {
|
||||||
|
reportDiagnosticSummary();
|
||||||
throw new RuntimeException("'" + pattern
|
throw new RuntimeException("'" + pattern
|
||||||
+ "' missing from stdout: [" + stdout + "]\n");
|
+ "' missing from stdout \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +193,9 @@ public final class OutputAnalyzer {
|
||||||
public void stderrShouldMatch(String pattern) {
|
public void stderrShouldMatch(String pattern) {
|
||||||
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
||||||
if (!matcher.find()) {
|
if (!matcher.find()) {
|
||||||
|
reportDiagnosticSummary();
|
||||||
throw new RuntimeException("'" + pattern
|
throw new RuntimeException("'" + pattern
|
||||||
+ "' missing from stderr: [" + stderr + "]\n");
|
+ "' missing from stderr \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,13 +209,15 @@ public final class OutputAnalyzer {
|
||||||
public void shouldNotMatch(String pattern) {
|
public void shouldNotMatch(String pattern) {
|
||||||
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
|
reportDiagnosticSummary();
|
||||||
throw new RuntimeException("'" + pattern
|
throw new RuntimeException("'" + pattern
|
||||||
+ "' found in stdout: [" + stdout + "]\n");
|
+ "' found in stdout \n");
|
||||||
}
|
}
|
||||||
matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
|
reportDiagnosticSummary();
|
||||||
throw new RuntimeException("'" + pattern
|
throw new RuntimeException("'" + pattern
|
||||||
+ "' found in stderr: [" + stderr + "]\n");
|
+ "' found in stderr \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,8 +231,9 @@ public final class OutputAnalyzer {
|
||||||
public void stdoutShouldNotMatch(String pattern) {
|
public void stdoutShouldNotMatch(String pattern) {
|
||||||
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
|
reportDiagnosticSummary();
|
||||||
throw new RuntimeException("'" + pattern
|
throw new RuntimeException("'" + pattern
|
||||||
+ "' found in stdout: [" + stdout + "]\n");
|
+ "' found in stdout \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,23 +247,45 @@ public final class OutputAnalyzer {
|
||||||
public void stderrShouldNotMatch(String pattern) {
|
public void stderrShouldNotMatch(String pattern) {
|
||||||
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
|
reportDiagnosticSummary();
|
||||||
throw new RuntimeException("'" + pattern
|
throw new RuntimeException("'" + pattern
|
||||||
+ "' found in stderr: [" + stderr + "]\n");
|
+ "' found in stderr \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifiy the exit value of the process
|
* Verify the exit value of the process
|
||||||
*
|
*
|
||||||
* @param expectedExitValue Expected exit value from process
|
* @param expectedExitValue Expected exit value from process
|
||||||
* @throws RuntimeException If the exit value from the process did not match the expected value
|
* @throws RuntimeException If the exit value from the process did not match the expected value
|
||||||
*/
|
*/
|
||||||
public void shouldHaveExitValue(int expectedExitValue) {
|
public void shouldHaveExitValue(int expectedExitValue) {
|
||||||
if (getExitValue() != expectedExitValue) {
|
if (getExitValue() != expectedExitValue) {
|
||||||
throw new RuntimeException("Exit value " + getExitValue() + " , expected to get " + expectedExitValue);
|
reportDiagnosticSummary();
|
||||||
|
throw new RuntimeException("Expected to get exit value of ["
|
||||||
|
+ expectedExitValue + "]\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report summary that will help to diagnose the problem
|
||||||
|
* Currently includes:
|
||||||
|
* - standard input produced by the process under test
|
||||||
|
* - standard output
|
||||||
|
* - exit code
|
||||||
|
* Note: the command line is printed by the ProcessTools
|
||||||
|
*/
|
||||||
|
private void reportDiagnosticSummary() {
|
||||||
|
String msg =
|
||||||
|
" stdout: [" + stdout + "];\n" +
|
||||||
|
" stderr: [" + stderr + "]\n" +
|
||||||
|
" exitValue = " + getExitValue() + "\n";
|
||||||
|
|
||||||
|
System.err.println(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the contents of the output buffer (stdout and stderr)
|
* Get the contents of the output buffer (stdout and stderr)
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class Platform {
|
||||||
private static final String osName = System.getProperty("os.name");
|
private static final String osName = System.getProperty("os.name");
|
||||||
private static final String dataModel = System.getProperty("sun.arch.data.model");
|
private static final String dataModel = System.getProperty("sun.arch.data.model");
|
||||||
private static final String vmVersion = System.getProperty("java.vm.version");
|
private static final String vmVersion = System.getProperty("java.vm.version");
|
||||||
|
private static final String osArch = System.getProperty("os.arch");
|
||||||
|
|
||||||
public static boolean is64bit() {
|
public static boolean is64bit() {
|
||||||
return dataModel.equals("64");
|
return dataModel.equals("64");
|
||||||
|
@ -59,4 +60,14 @@ public class Platform {
|
||||||
public static String getVMVersion() {
|
public static String getVMVersion() {
|
||||||
return vmVersion;
|
return vmVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true for sparc and sparcv9.
|
||||||
|
public static boolean isSparc() {
|
||||||
|
return osArch.toLowerCase().startsWith("sparc");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOsArch() {
|
||||||
|
return osArch;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import sun.management.VMManagement;
|
import sun.management.VMManagement;
|
||||||
|
|
||||||
|
@ -106,6 +107,22 @@ public final class ProcessTools {
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the string containing input arguments passed to the VM
|
||||||
|
*
|
||||||
|
* @return arguments
|
||||||
|
*/
|
||||||
|
public static String getVmInputArguments() {
|
||||||
|
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
|
||||||
|
|
||||||
|
List<String> args = runtime.getInputArguments();
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (String arg : args)
|
||||||
|
result.append(arg).append(' ');
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
|
* Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
|
||||||
*
|
*
|
||||||
|
@ -132,8 +149,13 @@ public final class ProcessTools {
|
||||||
Collections.addAll(args, getPlatformSpecificVMArgs());
|
Collections.addAll(args, getPlatformSpecificVMArgs());
|
||||||
Collections.addAll(args, command);
|
Collections.addAll(args, command);
|
||||||
|
|
||||||
return new ProcessBuilder(args.toArray(new String[args.size()]));
|
// Reporting
|
||||||
|
StringBuilder cmdLine = new StringBuilder();
|
||||||
|
for (String cmd : args)
|
||||||
|
cmdLine.append(cmd).append(' ');
|
||||||
|
System.out.println("Command line: [" + cmdLine.toString() + "]");
|
||||||
|
|
||||||
|
return new ProcessBuilder(args.toArray(new String[args.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,3 +222,5 @@ b8c5f4b6f0fffb44618fc609a584953c4ed67c0b jdk8-b95
|
||||||
15e5bb51bc0cd89304dc2f7f29b4c8002e632353 jdk8-b98
|
15e5bb51bc0cd89304dc2f7f29b4c8002e632353 jdk8-b98
|
||||||
adf49c3ef83c160d53ece623049b2cdccaf78fc7 jdk8-b99
|
adf49c3ef83c160d53ece623049b2cdccaf78fc7 jdk8-b99
|
||||||
5d1974c1d7b9a86431bc253dc5a6a52d4586622e jdk8-b100
|
5d1974c1d7b9a86431bc253dc5a6a52d4586622e jdk8-b100
|
||||||
|
0a7432f898e579ea35e8c51e3edab37f949168e4 jdk8-b101
|
||||||
|
7cffafa606e9fb865e7b5e6a56e0a681ce5cf617 jdk8-b102
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
|
||||||
/** Initial EntityResolver */
|
/** Initial EntityResolver */
|
||||||
private final EntityResolver fInitEntityResolver;
|
private final EntityResolver fInitEntityResolver;
|
||||||
|
|
||||||
private XMLSecurityPropertyManager fSecurityPropertyMgr;
|
private final XMLSecurityPropertyManager fSecurityPropertyMgr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a SAX parser with the associated features
|
* Create a SAX parser with the associated features
|
||||||
|
@ -130,8 +130,10 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
|
||||||
SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features, boolean secureProcessing)
|
SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features, boolean secureProcessing)
|
||||||
throws SAXException
|
throws SAXException
|
||||||
{
|
{
|
||||||
|
fSecurityPropertyMgr = new XMLSecurityPropertyManager();
|
||||||
|
|
||||||
// Instantiate a SAXParser directly and not through SAX so that we use the right ClassLoader
|
// Instantiate a SAXParser directly and not through SAX so that we use the right ClassLoader
|
||||||
xmlReader = new JAXPSAXParser(this);
|
xmlReader = new JAXPSAXParser(this, fSecurityPropertyMgr);
|
||||||
|
|
||||||
// JAXP "namespaceAware" == SAX Namespaces feature
|
// JAXP "namespaceAware" == SAX Namespaces feature
|
||||||
// Note: there is a compatibility problem here with default values:
|
// Note: there is a compatibility problem here with default values:
|
||||||
|
@ -150,7 +152,6 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
|
||||||
xmlReader.setFeature0(XINCLUDE_FEATURE, true);
|
xmlReader.setFeature0(XINCLUDE_FEATURE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
fSecurityPropertyMgr = new XMLSecurityPropertyManager();
|
|
||||||
xmlReader.setProperty0(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
|
xmlReader.setProperty0(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
|
||||||
|
|
||||||
// If the secure processing feature is on set a security manager.
|
// If the secure processing feature is on set a security manager.
|
||||||
|
@ -397,14 +398,30 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
|
||||||
private final HashMap fInitFeatures = new HashMap();
|
private final HashMap fInitFeatures = new HashMap();
|
||||||
private final HashMap fInitProperties = new HashMap();
|
private final HashMap fInitProperties = new HashMap();
|
||||||
private final SAXParserImpl fSAXParser;
|
private final SAXParserImpl fSAXParser;
|
||||||
|
private XMLSecurityPropertyManager fSecurityPropertyMgr;
|
||||||
|
|
||||||
|
|
||||||
public JAXPSAXParser() {
|
public JAXPSAXParser() {
|
||||||
this(null);
|
this(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
JAXPSAXParser(SAXParserImpl saxParser) {
|
JAXPSAXParser(SAXParserImpl saxParser, XMLSecurityPropertyManager spm) {
|
||||||
super();
|
super();
|
||||||
fSAXParser = saxParser;
|
fSAXParser = saxParser;
|
||||||
|
fSecurityPropertyMgr = spm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class may be used directly. So initialize the security manager if
|
||||||
|
* it is null.
|
||||||
|
*/
|
||||||
|
if (fSecurityPropertyMgr == null) {
|
||||||
|
fSecurityPropertyMgr = new XMLSecurityPropertyManager();
|
||||||
|
try {
|
||||||
|
super.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
//shall not happen
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -542,9 +559,9 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
|
||||||
setSchemaValidatorProperty(name, value);
|
setSchemaValidatorProperty(name, value);
|
||||||
}
|
}
|
||||||
/** Check to see if the property is managed by the property manager **/
|
/** Check to see if the property is managed by the property manager **/
|
||||||
int index = fSAXParser.fSecurityPropertyMgr.getIndex(name);
|
int index = (fSecurityPropertyMgr != null) ? fSecurityPropertyMgr.getIndex(name) : -1;
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
fSAXParser.fSecurityPropertyMgr.setValue(index,
|
fSecurityPropertyMgr.setValue(index,
|
||||||
XMLSecurityPropertyManager.State.APIPROPERTY, (String)value);
|
XMLSecurityPropertyManager.State.APIPROPERTY, (String)value);
|
||||||
} else {
|
} else {
|
||||||
if (!fInitProperties.containsKey(name)) {
|
if (!fInitProperties.containsKey(name)) {
|
||||||
|
@ -564,9 +581,9 @@ public class SAXParserImpl extends javax.xml.parsers.SAXParser
|
||||||
// JAXP 1.2 support
|
// JAXP 1.2 support
|
||||||
return fSAXParser.schemaLanguage;
|
return fSAXParser.schemaLanguage;
|
||||||
}
|
}
|
||||||
int index = fSAXParser.fSecurityPropertyMgr.getIndex(name);
|
int index = (fSecurityPropertyMgr != null) ? fSecurityPropertyMgr.getIndex(name) : -1;
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return fSAXParser.fSecurityPropertyMgr.getValueByIndex(index);
|
return fSecurityPropertyMgr.getValueByIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getProperty(name);
|
return super.getProperty(name);
|
||||||
|
|
|
@ -222,3 +222,5 @@ dcde7f049111353ad23175f54985a4f6bfea720c jdk8-b97
|
||||||
b1fb4612a2caea52b5661b87509e560fa044b194 jdk8-b98
|
b1fb4612a2caea52b5661b87509e560fa044b194 jdk8-b98
|
||||||
8ef83d4b23c933935e28f59b282cea920b1b1f5f jdk8-b99
|
8ef83d4b23c933935e28f59b282cea920b1b1f5f jdk8-b99
|
||||||
4fd722afae5c02f00bbd44c3a34425ee474afb1c jdk8-b100
|
4fd722afae5c02f00bbd44c3a34425ee474afb1c jdk8-b100
|
||||||
|
60b623a361642a0f5aef5f06dad9e5f279b9d9a9 jdk8-b101
|
||||||
|
988a5f2ac559dcab05698b8a8633aa453e012260 jdk8-b102
|
||||||
|
|
|
@ -222,3 +222,5 @@ a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92
|
||||||
c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98
|
c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98
|
||||||
6a099a36589bd933957272ba63e5263bede29971 jdk8-b99
|
6a099a36589bd933957272ba63e5263bede29971 jdk8-b99
|
||||||
5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100
|
5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100
|
||||||
|
6901612328239fbd471d20823113c1cf3fdaebee jdk8-b101
|
||||||
|
8ed8e2b4b90e0ac9aa5b3efef51cd576a9db96a9 jdk8-b102
|
||||||
|
|
|
@ -798,6 +798,16 @@ ifeq ($(OPENJDK_TARGET_OS),solaris)
|
||||||
LIBAWT_XAWT_CFLAGS += -DFUNCPROTO=15
|
LIBAWT_XAWT_CFLAGS += -DFUNCPROTO=15
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OPENJDK_TARGET_OS),linux)
|
||||||
|
ifndef OPENJDK
|
||||||
|
include $(JDK_TOPDIR)/make/closed/xawt.gmk
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(DISABLE_XRENDER),true)
|
||||||
|
LIBAWT_XAWT_CFLAGS += -DDISABLE_XRENDER_BY_DEFAULT=true
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(MILESTONE),internal)
|
ifeq ($(MILESTONE),internal)
|
||||||
LIBAWT_XAWT_CFLAGS += -DINTERNAL_BUILD
|
LIBAWT_XAWT_CFLAGS += -DINTERNAL_BUILD
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.awt.peer.MenuComponentPeer;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.plaf.MenuBarUI;
|
import javax.swing.plaf.MenuBarUI;
|
||||||
|
|
||||||
|
import com.apple.laf.ScreenMenuBar;
|
||||||
import sun.lwawt.macosx.CMenuBar;
|
import sun.lwawt.macosx.CMenuBar;
|
||||||
|
|
||||||
import com.apple.laf.AquaMenuBarUI;
|
import com.apple.laf.AquaMenuBarUI;
|
||||||
|
@ -72,12 +73,15 @@ class _AppMenuBarHandler {
|
||||||
// scan the current frames, and see if any are foreground
|
// scan the current frames, and see if any are foreground
|
||||||
final Frame[] frames = Frame.getFrames();
|
final Frame[] frames = Frame.getFrames();
|
||||||
for (final Frame frame : frames) {
|
for (final Frame frame : frames) {
|
||||||
if (frame.isVisible() && !isFrameMinimized(frame)) return;
|
if (frame.isVisible() && !isFrameMinimized(frame)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have no foreground frames, then we have to "kick" the menubar
|
// if we have no foreground frames, then we have to "kick" the menubar
|
||||||
final JFrame pingFrame = new JFrame();
|
final JFrame pingFrame = new JFrame();
|
||||||
pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
|
pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
|
||||||
|
pingFrame.setUndecorated(true);
|
||||||
pingFrame.setVisible(true);
|
pingFrame.setVisible(true);
|
||||||
pingFrame.toFront();
|
pingFrame.toFront();
|
||||||
pingFrame.setVisible(false);
|
pingFrame.setVisible(false);
|
||||||
|
@ -101,7 +105,6 @@ class _AppMenuBarHandler {
|
||||||
// Aqua was not installed
|
// Aqua was not installed
|
||||||
throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
|
throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
|
||||||
}
|
}
|
||||||
/* TODO: disabled until ScreenMenuBar is working
|
|
||||||
|
|
||||||
final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
|
final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
|
||||||
final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
|
final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
|
||||||
|
@ -118,8 +121,7 @@ class _AppMenuBarHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// grab the pointer to the CMenuBar, and retain it in native
|
// grab the pointer to the CMenuBar, and retain it in native
|
||||||
nativeSetDefaultMenuBar(((CMenuBar)peer).getNativeMenuBarPeer());
|
nativeSetDefaultMenuBar(((CMenuBar)peer).getModel());
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAboutMenuItemVisible(final boolean present) {
|
void setAboutMenuItemVisible(final boolean present) {
|
||||||
|
|
|
@ -1856,7 +1856,10 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
|
||||||
// If we're not valid that means we will shortly be validated and
|
// If we're not valid that means we will shortly be validated and
|
||||||
// painted, which means we don't have to do anything here.
|
// painted, which means we don't have to do anything here.
|
||||||
if (!isRunsDirty && index >= 0 && index < tabPane.getTabCount()) {
|
if (!isRunsDirty && index >= 0 && index < tabPane.getTabCount()) {
|
||||||
tabPane.repaint(getTabBounds(tabPane, index));
|
Rectangle rect = getTabBounds(tabPane, index);
|
||||||
|
if (rect != null) {
|
||||||
|
tabPane.repaint(rect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -701,6 +701,20 @@ public class AquaTabbedPaneUI extends AquaTabbedPaneCopyFromBasicUI {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bounds of the specified tab index. The bounds are
|
||||||
|
* with respect to the JTabbedPane's coordinate space. If the tab at this
|
||||||
|
* index is not currently visible in the UI, then returns null.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Rectangle getTabBounds(final JTabbedPane pane, final int i) {
|
||||||
|
if (visibleTabState.needsScrollTabs()
|
||||||
|
&& (visibleTabState.isBefore(i) || visibleTabState.isAfter(i))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return super.getTabBounds(pane, i);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the tab index which intersects the specified point
|
* Returns the tab index which intersects the specified point
|
||||||
* in the JTabbedPane's coordinate space.
|
* in the JTabbedPane's coordinate space.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -31,7 +31,7 @@ import java.util.*;
|
||||||
|
|
||||||
import sun.awt.SunHints;
|
import sun.awt.SunHints;
|
||||||
|
|
||||||
public class CStrike extends FontStrike {
|
public final class CStrike extends FontStrike {
|
||||||
|
|
||||||
// Creates the native strike
|
// Creates the native strike
|
||||||
private static native long createNativeStrikePtr(long nativeFontPtr,
|
private static native long createNativeStrikePtr(long nativeFontPtr,
|
||||||
|
@ -68,10 +68,10 @@ public class CStrike extends FontStrike {
|
||||||
Rectangle2D.Float result,
|
Rectangle2D.Float result,
|
||||||
double x, double y);
|
double x, double y);
|
||||||
|
|
||||||
private CFont nativeFont;
|
private final CFont nativeFont;
|
||||||
private AffineTransform invDevTx;
|
private AffineTransform invDevTx;
|
||||||
private GlyphInfoCache glyphInfoCache;
|
private final GlyphInfoCache glyphInfoCache;
|
||||||
private GlyphAdvanceCache glyphAdvanceCache;
|
private final GlyphAdvanceCache glyphAdvanceCache;
|
||||||
private long nativeStrikePtr;
|
private long nativeStrikePtr;
|
||||||
|
|
||||||
CStrike(final CFont font, final FontStrikeDesc inDesc) {
|
CStrike(final CFont font, final FontStrikeDesc inDesc) {
|
||||||
|
@ -84,11 +84,11 @@ public class CStrike extends FontStrike {
|
||||||
// Normally the device transform should be the identity transform
|
// Normally the device transform should be the identity transform
|
||||||
// for screen operations. The device transform only becomes
|
// for screen operations. The device transform only becomes
|
||||||
// interesting when we are outputting between different dpi surfaces,
|
// interesting when we are outputting between different dpi surfaces,
|
||||||
// like when we are printing to postscript.
|
// like when we are printing to postscript or use retina.
|
||||||
if (inDesc.devTx != null && !inDesc.devTx.isIdentity()) {
|
if (inDesc.devTx != null && !inDesc.devTx.isIdentity()) {
|
||||||
try {
|
try {
|
||||||
invDevTx = inDesc.devTx.createInverse();
|
invDevTx = inDesc.devTx.createInverse();
|
||||||
} catch (NoninvertibleTransformException e) {
|
} catch (NoninvertibleTransformException ignored) {
|
||||||
// ignored, since device transforms should not be that
|
// ignored, since device transforms should not be that
|
||||||
// complicated, and if they are - there is nothing we can do,
|
// complicated, and if they are - there is nothing we can do,
|
||||||
// so we won't worry about it.
|
// so we won't worry about it.
|
||||||
|
@ -134,15 +134,13 @@ public class CStrike extends FontStrike {
|
||||||
nativeStrikePtr = 0;
|
nativeStrikePtr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the fractional metrics default on our platform is OFF
|
|
||||||
private boolean useFractionalMetrics() {
|
|
||||||
return desc.fmHint == SunHints.INTVAL_FRACTIONALMETRICS_ON;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNumGlyphs() {
|
public int getNumGlyphs() {
|
||||||
return nativeFont.getNumGlyphs();
|
return nativeFont.getNumGlyphs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
StrikeMetrics getFontMetrics() {
|
StrikeMetrics getFontMetrics() {
|
||||||
if (strikeMetrics == null) {
|
if (strikeMetrics == null) {
|
||||||
StrikeMetrics metrics = getFontMetrics(getNativeStrikePtr());
|
StrikeMetrics metrics = getFontMetrics(getNativeStrikePtr());
|
||||||
|
@ -155,74 +153,24 @@ public class CStrike extends FontStrike {
|
||||||
return strikeMetrics;
|
return strikeMetrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getGlyphAdvance(int glyphCode) {
|
@Override
|
||||||
return getScaledAdvanceForAdvance(getCachedNativeGlyphAdvance(glyphCode));
|
float getGlyphAdvance(final int glyphCode) {
|
||||||
|
return getCachedNativeGlyphAdvance(glyphCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getCodePointAdvance(int cp) {
|
@Override
|
||||||
float advance = getCachedNativeGlyphAdvance(nativeFont.getMapper().charToGlyph(cp));
|
float getCodePointAdvance(final int cp) {
|
||||||
|
return getGlyphAdvance(nativeFont.getMapper().charToGlyph(cp));
|
||||||
double glyphScaleX = desc.glyphTx.getScaleX();
|
|
||||||
double devScaleX = desc.devTx.getScaleX();
|
|
||||||
|
|
||||||
if (devScaleX == 0) {
|
|
||||||
glyphScaleX = Math.sqrt(desc.glyphTx.getDeterminant());
|
|
||||||
devScaleX = Math.sqrt(desc.devTx.getDeterminant());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (devScaleX == 0) {
|
|
||||||
devScaleX = Double.NaN; // this an undefined graphics state
|
|
||||||
}
|
|
||||||
advance = (float) (advance * glyphScaleX / devScaleX);
|
|
||||||
return useFractionalMetrics() ? advance : Math.round(advance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate an advance, and round if not using fractional metrics
|
@Override
|
||||||
private float getScaledAdvanceForAdvance(float advance) {
|
Point2D.Float getCharMetrics(final char ch) {
|
||||||
if (invDevTx != null) {
|
return getGlyphMetrics(nativeFont.getMapper().charToGlyph(ch));
|
||||||
advance *= invDevTx.getScaleX();
|
|
||||||
}
|
|
||||||
advance *= desc.glyphTx.getScaleX();
|
|
||||||
return useFractionalMetrics() ? advance : Math.round(advance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Point2D.Float getCharMetrics(char ch) {
|
@Override
|
||||||
return getScaledPointForAdvance(getCachedNativeGlyphAdvance(nativeFont.getMapper().charToGlyph(ch)));
|
Point2D.Float getGlyphMetrics(final int glyphCode) {
|
||||||
}
|
return new Point2D.Float(getGlyphAdvance(glyphCode), 0.0f);
|
||||||
|
|
||||||
Point2D.Float getGlyphMetrics(int glyphCode) {
|
|
||||||
return getScaledPointForAdvance(getCachedNativeGlyphAdvance(glyphCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate an advance point, and round if not using fractional metrics
|
|
||||||
private Point2D.Float getScaledPointForAdvance(float advance) {
|
|
||||||
Point2D.Float pt = new Point2D.Float(advance, 0);
|
|
||||||
|
|
||||||
if (!desc.glyphTx.isIdentity()) {
|
|
||||||
return scalePoint(pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!useFractionalMetrics()) {
|
|
||||||
pt.x = Math.round(pt.x);
|
|
||||||
}
|
|
||||||
return pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point2D.Float scalePoint(Point2D.Float pt) {
|
|
||||||
if (invDevTx != null) {
|
|
||||||
// transform the point out of the device space first
|
|
||||||
invDevTx.transform(pt, pt);
|
|
||||||
}
|
|
||||||
desc.glyphTx.transform(pt, pt);
|
|
||||||
pt.x -= desc.glyphTx.getTranslateX();
|
|
||||||
pt.y -= desc.glyphTx.getTranslateY();
|
|
||||||
|
|
||||||
if (!useFractionalMetrics()) {
|
|
||||||
pt.x = Math.round(pt.x);
|
|
||||||
pt.y = Math.round(pt.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {
|
Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {
|
||||||
|
@ -414,9 +362,7 @@ public class CStrike extends FontStrike {
|
||||||
private SparseBitShiftingTwoLayerArray secondLayerCache;
|
private SparseBitShiftingTwoLayerArray secondLayerCache;
|
||||||
private HashMap<Integer, Long> generalCache;
|
private HashMap<Integer, Long> generalCache;
|
||||||
|
|
||||||
public GlyphInfoCache(final Font2D nativeFont,
|
GlyphInfoCache(final Font2D nativeFont, final FontStrikeDesc desc) {
|
||||||
final FontStrikeDesc desc)
|
|
||||||
{
|
|
||||||
super(nativeFont, desc);
|
super(nativeFont, desc);
|
||||||
firstLayerCache = new long[FIRST_LAYER_SIZE];
|
firstLayerCache = new long[FIRST_LAYER_SIZE];
|
||||||
}
|
}
|
||||||
|
@ -527,7 +473,7 @@ public class CStrike extends FontStrike {
|
||||||
final int shift;
|
final int shift;
|
||||||
final int secondLayerLength;
|
final int secondLayerLength;
|
||||||
|
|
||||||
public SparseBitShiftingTwoLayerArray(final int size, final int shift) {
|
SparseBitShiftingTwoLayerArray(final int size, final int shift) {
|
||||||
this.shift = shift;
|
this.shift = shift;
|
||||||
this.cache = new long[1 << shift][];
|
this.cache = new long[1 << shift][];
|
||||||
this.secondLayerLength = size >> shift;
|
this.secondLayerLength = size >> shift;
|
||||||
|
@ -559,6 +505,12 @@ public class CStrike extends FontStrike {
|
||||||
private SparseBitShiftingTwoLayerArray secondLayerCache;
|
private SparseBitShiftingTwoLayerArray secondLayerCache;
|
||||||
private HashMap<Integer, Float> generalCache;
|
private HashMap<Integer, Float> generalCache;
|
||||||
|
|
||||||
|
// Empty non private constructor was added because access to this
|
||||||
|
// class shouldn't be emulated by a synthetic accessor method.
|
||||||
|
GlyphAdvanceCache() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized float get(final int index) {
|
public synchronized float get(final int index) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
if (-index < SECOND_LAYER_SIZE) {
|
if (-index < SECOND_LAYER_SIZE) {
|
||||||
|
@ -609,9 +561,7 @@ public class CStrike extends FontStrike {
|
||||||
final int shift;
|
final int shift;
|
||||||
final int secondLayerLength;
|
final int secondLayerLength;
|
||||||
|
|
||||||
public SparseBitShiftingTwoLayerArray(final int size,
|
SparseBitShiftingTwoLayerArray(final int size, final int shift) {
|
||||||
final int shift)
|
|
||||||
{
|
|
||||||
this.shift = shift;
|
this.shift = shift;
|
||||||
this.cache = new float[1 << shift][];
|
this.cache = new float[1 << shift][];
|
||||||
this.secondLayerLength = size >> shift;
|
this.secondLayerLength = size >> shift;
|
||||||
|
|
|
@ -182,7 +182,11 @@ public class CDataTransferer extends DataTransferer {
|
||||||
Long format = predefinedClipboardNameMap.get(str);
|
Long format = predefinedClipboardNameMap.get(str);
|
||||||
|
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
format = new Long(registerFormatWithPasteboard(str));
|
if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
|
||||||
|
// Do not try to access native system for the unknown format
|
||||||
|
return -1L;
|
||||||
|
}
|
||||||
|
format = registerFormatWithPasteboard(str);
|
||||||
predefinedClipboardNameMap.put(str, format);
|
predefinedClipboardNameMap.put(str, format);
|
||||||
predefinedClipboardFormatMap.put(format, str);
|
predefinedClipboardFormatMap.put(format, str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public abstract class CMenuComponent implements MenuComponentPeer {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
long getModel() {
|
public long getModel() {
|
||||||
return modelPtr;
|
return modelPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ import com.apple.laf.ClientPropertyApplicator.Property;
|
||||||
import com.sun.awt.AWTUtilities;
|
import com.sun.awt.AWTUtilities;
|
||||||
|
|
||||||
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
||||||
private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
|
private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
|
||||||
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
|
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
|
||||||
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
|
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
|
||||||
private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
|
private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
|
||||||
|
@ -230,7 +230,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||||
contentView = createContentView();
|
contentView = createContentView();
|
||||||
contentView.initialize(peer, responder);
|
contentView.initialize(peer, responder);
|
||||||
|
|
||||||
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), styleBits, 0, 0, 0, 0);
|
final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
|
||||||
|
final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), ownerPtr, styleBits, 0, 0, 0, 0);
|
||||||
setPtr(nativeWindowPtr);
|
setPtr(nativeWindowPtr);
|
||||||
|
|
||||||
if (target instanceof javax.swing.RootPaneContainer) {
|
if (target instanceof javax.swing.RootPaneContainer) {
|
||||||
|
@ -829,18 +830,19 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||||
// UTILITY METHODS
|
// UTILITY METHODS
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Find image to install into Title or into Application icon.
|
* Find image to install into Title or into Application icon. First try
|
||||||
* First try icons installed for toplevel. If there is no icon
|
* icons installed for toplevel. Null is returned, if there is no icon and
|
||||||
* use default Duke image.
|
* default Duke image should be used.
|
||||||
* This method shouldn't return null.
|
|
||||||
*/
|
*/
|
||||||
private CImage getImageForTarget() {
|
private CImage getImageForTarget() {
|
||||||
List<Image> icons = target.getIconImages();
|
CImage icon = null;
|
||||||
if (icons == null || icons.size() == 0) {
|
try {
|
||||||
return null;
|
icon = CImage.getCreator().createFromImages(target.getIconImages());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Perhaps the icon passed into Java is broken. Skipping this icon.
|
||||||
}
|
}
|
||||||
return CImage.getCreator().createFromImages(icons);
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -103,7 +103,6 @@ NSDictionary *realmConfigsForRealms(SCDynamicStoreRef store, NSArray *realms) {
|
||||||
CFTypeRef realmInfo = SCDynamicStoreCopyValue(store, (CFStringRef) [NSString stringWithFormat:@"Kerberos:%@", realm]);
|
CFTypeRef realmInfo = SCDynamicStoreCopyValue(store, (CFStringRef) [NSString stringWithFormat:@"Kerberos:%@", realm]);
|
||||||
|
|
||||||
if (CFGetTypeID(realmInfo) != CFDictionaryGetTypeID()) {
|
if (CFGetTypeID(realmInfo) != CFDictionaryGetTypeID()) {
|
||||||
NSLog(@"Unexpected CFType for realm Info: %lu", CFGetTypeID(realmInfo));
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +139,6 @@ JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java"), _SCDynamicStoreCallBack, NULL);
|
SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java"), _SCDynamicStoreCallBack, NULL);
|
||||||
if (store == NULL) {
|
if (store == NULL) {
|
||||||
NSLog(@"Unable to load SCDynamicStore to install NotificationCallback");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,19 +169,11 @@ JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL);
|
SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL);
|
||||||
if (store == NULL) {
|
if (store == NULL) {
|
||||||
NSLog(@"Unable to load SCDynamicStore");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the store if it is NULL and set it.
|
|
||||||
if (store == NULL) {
|
|
||||||
NSLog(@"Invalid value for SCDynamicStore");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFTypeRef realms = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS);
|
CFTypeRef realms = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS);
|
||||||
if (realms == NULL || CFGetTypeID(realms) != CFArrayGetTypeID()) {
|
if (realms == NULL || CFGetTypeID(realms) != CFArrayGetTypeID()) {
|
||||||
NSLog(@"Unable to load realm info from SCDynamicStore");
|
|
||||||
if (realms) CFRelease(realms);
|
if (realms) CFRelease(realms);
|
||||||
CFRelease(store);
|
CFRelease(store);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -192,7 +182,6 @@ JNF_COCOA_ENTER(env);
|
||||||
CFTypeRef realmMappings = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS);
|
CFTypeRef realmMappings = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS);
|
||||||
|
|
||||||
if (realmMappings == NULL || CFGetTypeID(realmMappings) != CFArrayGetTypeID()) {
|
if (realmMappings == NULL || CFGetTypeID(realmMappings) != CFArrayGetTypeID()) {
|
||||||
NSLog(@"Unable to load realm mapping info from SCDynamicStore");
|
|
||||||
if (realmMappings) CFRelease(realmMappings);
|
if (realmMappings) CFRelease(realmMappings);
|
||||||
CFRelease(realms);
|
CFRelease(realms);
|
||||||
CFRelease(store);
|
CFRelease(store);
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
jint styleBits;
|
jint styleBits;
|
||||||
BOOL isEnabled;
|
BOOL isEnabled;
|
||||||
NSWindow *nsWindow;
|
NSWindow *nsWindow;
|
||||||
|
AWTWindow *ownerWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// An instance of either AWTWindow_Normal or AWTWindow_Panel
|
// An instance of either AWTWindow_Normal or AWTWindow_Panel
|
||||||
|
@ -51,12 +52,15 @@
|
||||||
|
|
||||||
@property (nonatomic, retain) JNFWeakJObjectWrapper *javaPlatformWindow;
|
@property (nonatomic, retain) JNFWeakJObjectWrapper *javaPlatformWindow;
|
||||||
@property (nonatomic, retain) CMenuBar *javaMenuBar;
|
@property (nonatomic, retain) CMenuBar *javaMenuBar;
|
||||||
|
@property (nonatomic, retain) AWTWindow *ownerWindow;
|
||||||
@property (nonatomic) NSSize javaMinSize;
|
@property (nonatomic) NSSize javaMinSize;
|
||||||
@property (nonatomic) NSSize javaMaxSize;
|
@property (nonatomic) NSSize javaMaxSize;
|
||||||
@property (nonatomic) jint styleBits;
|
@property (nonatomic) jint styleBits;
|
||||||
@property (nonatomic) BOOL isEnabled;
|
@property (nonatomic) BOOL isEnabled;
|
||||||
|
|
||||||
|
|
||||||
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
|
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
|
||||||
|
ownerWindow:owner
|
||||||
styleBits:(jint)styleBits
|
styleBits:(jint)styleBits
|
||||||
frameRect:(NSRect)frameRect
|
frameRect:(NSRect)frameRect
|
||||||
contentView:(NSView *)contentView;
|
contentView:(NSView *)contentView;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#import "sun_lwawt_macosx_CPlatformWindow.h"
|
#import "sun_lwawt_macosx_CPlatformWindow.h"
|
||||||
#import "com_apple_eawt_event_GestureHandler.h"
|
#import "com_apple_eawt_event_GestureHandler.h"
|
||||||
#import "com_apple_eawt_FullScreenHandler.h"
|
#import "com_apple_eawt_FullScreenHandler.h"
|
||||||
|
#import "ApplicationDelegate.h"
|
||||||
|
|
||||||
#import "AWTWindow.h"
|
#import "AWTWindow.h"
|
||||||
#import "AWTView.h"
|
#import "AWTView.h"
|
||||||
|
@ -55,7 +56,7 @@ static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
|
||||||
// doesn't provide information about "opposite" window, so we
|
// doesn't provide information about "opposite" window, so we
|
||||||
// have to do a bit of tracking. This variable points to a window
|
// have to do a bit of tracking. This variable points to a window
|
||||||
// which had been the key window just before a new key window
|
// which had been the key window just before a new key window
|
||||||
// was set. It would be nil if the new key window isn't an AWT
|
// was set. It would be nil if the new key window isn't an AWT
|
||||||
// window or the app currently has no key window.
|
// window or the app currently has no key window.
|
||||||
static AWTWindow* lastKeyWindow = nil;
|
static AWTWindow* lastKeyWindow = nil;
|
||||||
|
|
||||||
|
@ -120,6 +121,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||||
@synthesize javaMaxSize;
|
@synthesize javaMaxSize;
|
||||||
@synthesize styleBits;
|
@synthesize styleBits;
|
||||||
@synthesize isEnabled;
|
@synthesize isEnabled;
|
||||||
|
@synthesize ownerWindow;
|
||||||
|
|
||||||
- (void) updateMinMaxSize:(BOOL)resizable {
|
- (void) updateMinMaxSize:(BOOL)resizable {
|
||||||
if (resizable) {
|
if (resizable) {
|
||||||
|
@ -201,6 +203,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
|
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
|
||||||
|
ownerWindow:owner
|
||||||
styleBits:(jint)bits
|
styleBits:(jint)bits
|
||||||
frameRect:(NSRect)rect
|
frameRect:(NSRect)rect
|
||||||
contentView:(NSView *)view
|
contentView:(NSView *)view
|
||||||
|
@ -245,6 +248,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||||
self.isEnabled = YES;
|
self.isEnabled = YES;
|
||||||
self.javaPlatformWindow = platformWindow;
|
self.javaPlatformWindow = platformWindow;
|
||||||
self.styleBits = bits;
|
self.styleBits = bits;
|
||||||
|
self.ownerWindow = owner;
|
||||||
[self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
|
[self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -350,7 +354,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||||
[self.javaPlatformWindow setJObject:nil withEnv:env];
|
[self.javaPlatformWindow setJObject:nil withEnv:env];
|
||||||
|
|
||||||
self.nsWindow = nil;
|
self.nsWindow = nil;
|
||||||
|
self.ownerWindow = nil;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,11 +543,27 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||||
AWT_ASSERT_APPKIT_THREAD;
|
AWT_ASSERT_APPKIT_THREAD;
|
||||||
[AWTToolkit eventCountPlusPlus];
|
[AWTToolkit eventCountPlusPlus];
|
||||||
AWTWindow *opposite = [AWTWindow lastKeyWindow];
|
AWTWindow *opposite = [AWTWindow lastKeyWindow];
|
||||||
if (!IS(self.styleBits, IS_DIALOG)) {
|
|
||||||
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
|
// Finds appropriate menubar in our hierarchy,
|
||||||
} else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) {
|
AWTWindow *awtWindow = self;
|
||||||
[CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES];
|
while (awtWindow.ownerWindow != nil) {
|
||||||
|
awtWindow = awtWindow.ownerWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMenuBar *menuBar = nil;
|
||||||
|
BOOL isDisabled = NO;
|
||||||
|
if ([awtWindow.nsWindow isVisible]){
|
||||||
|
menuBar = awtWindow.javaMenuBar;
|
||||||
|
isDisabled = !awtWindow.isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menuBar == nil) {
|
||||||
|
menuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
|
||||||
|
isDisabled = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CMenuBar activate:menuBar modallyDisabled:isDisabled];
|
||||||
|
|
||||||
[AWTWindow setLastKeyWindow:nil];
|
[AWTWindow setLastKeyWindow:nil];
|
||||||
|
|
||||||
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
|
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
|
||||||
|
@ -555,6 +575,14 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||||
[AWTToolkit eventCountPlusPlus];
|
[AWTToolkit eventCountPlusPlus];
|
||||||
[self.javaMenuBar deactivate];
|
[self.javaMenuBar deactivate];
|
||||||
|
|
||||||
|
// In theory, this might cause flickering if the window gaining focus
|
||||||
|
// has its own menu. However, I couldn't reproduce it on practice, so
|
||||||
|
// perhaps this is a non issue.
|
||||||
|
CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
|
||||||
|
if (defaultMenu != nil) {
|
||||||
|
[CMenuBar activate:defaultMenu modallyDisabled:NO];
|
||||||
|
}
|
||||||
|
|
||||||
// the new key window
|
// the new key window
|
||||||
NSWindow *keyWindow = [NSApp keyWindow];
|
NSWindow *keyWindow = [NSApp keyWindow];
|
||||||
AWTWindow *opposite = nil;
|
AWTWindow *opposite = nil;
|
||||||
|
@ -741,7 +769,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||||
* Signature: (JJIIII)J
|
* Signature: (JJIIII)J
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow
|
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow
|
||||||
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h)
|
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong ownerPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h)
|
||||||
{
|
{
|
||||||
__block AWTWindow *window = nil;
|
__block AWTWindow *window = nil;
|
||||||
|
|
||||||
|
@ -750,13 +778,14 @@ JNF_COCOA_ENTER(env);
|
||||||
JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
|
JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
|
||||||
NSView *contentView = OBJC(contentViewPtr);
|
NSView *contentView = OBJC(contentViewPtr);
|
||||||
NSRect frameRect = NSMakeRect(x, y, w, h);
|
NSRect frameRect = NSMakeRect(x, y, w, h);
|
||||||
|
AWTWindow *owner = [OBJC(ownerPtr) delegate];
|
||||||
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
|
||||||
|
|
||||||
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
|
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
|
||||||
styleBits:styleBits
|
ownerWindow:owner
|
||||||
frameRect:frameRect
|
styleBits:styleBits
|
||||||
contentView:contentView];
|
frameRect:frameRect
|
||||||
|
contentView:contentView];
|
||||||
// the window is released is CPlatformWindow.nativeDispose()
|
// the window is released is CPlatformWindow.nativeDispose()
|
||||||
|
|
||||||
if (window) CFRetain(window.nsWindow);
|
if (window) CFRetain(window.nsWindow);
|
||||||
|
@ -818,11 +847,19 @@ JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
|
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
|
||||||
|
|
||||||
if ([nsWindow isKeyWindow]) [window.javaMenuBar deactivate];
|
if ([nsWindow isKeyWindow]) {
|
||||||
|
[window.javaMenuBar deactivate];
|
||||||
|
}
|
||||||
|
|
||||||
window.javaMenuBar = menuBar;
|
window.javaMenuBar = menuBar;
|
||||||
|
|
||||||
|
CMenuBar* actualMenuBar = menuBar;
|
||||||
|
if (actualMenuBar == nil) {
|
||||||
|
actualMenuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar];
|
||||||
|
}
|
||||||
|
|
||||||
if ([nsWindow isKeyWindow]) {
|
if ([nsWindow isKeyWindow]) {
|
||||||
[CMenuBar activate:window.javaMenuBar modallyDisabled:NO];
|
[CMenuBar activate:actualMenuBar modallyDisabled:NO];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ static BOOL sSetupHelpMenu = NO;
|
||||||
if (excludingAppleMenu && ![currMenu isJavaMenu]) {
|
if (excludingAppleMenu && ![currMenu isJavaMenu]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
[currItem setSubmenu:nil];
|
||||||
[theMainMenu removeItemAtIndex:index];
|
[theMainMenu removeItemAtIndex:index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,10 @@ static BOOL sSetupHelpMenu = NO;
|
||||||
// Clean up extra items
|
// Clean up extra items
|
||||||
NSUInteger removedIndex, removedCount = [removedMenuArray count];
|
NSUInteger removedIndex, removedCount = [removedMenuArray count];
|
||||||
for (removedIndex=removedCount; removedIndex > 0; removedIndex--) {
|
for (removedIndex=removedCount; removedIndex > 0; removedIndex--) {
|
||||||
[theMainMenu removeItemAtIndex:[[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue]];
|
NSUInteger index = [[removedMenuArray objectAtIndex:(removedIndex-1)] integerValue];
|
||||||
|
NSMenuItem *currItem = [theMainMenu itemAtIndex:index];
|
||||||
|
[currItem setSubmenu:nil];
|
||||||
|
[theMainMenu removeItemAtIndex:index];
|
||||||
}
|
}
|
||||||
|
|
||||||
i = cmenuIndex;
|
i = cmenuIndex;
|
||||||
|
|
|
@ -70,9 +70,15 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||||
JNF_COCOA_ENTER(env);
|
JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
// If we are called as a result of user pressing a shorcut, do nothing,
|
// If we are called as a result of user pressing a shortcut, do nothing,
|
||||||
// because AVTView has already sent corresponding key event to the Java
|
// because AVTView has already sent corresponding key event to the Java
|
||||||
// layer from performKeyEquivalent
|
// layer from performKeyEquivalent.
|
||||||
|
// There is an exception from the rule above, though: if a window with
|
||||||
|
// a menu gets minimized by user and there are no other windows to take
|
||||||
|
// focus, the window's menu won't be removed from the global menu bar.
|
||||||
|
// However, the Java layer won't handle invocation by a shortcut coming
|
||||||
|
// from this "frameless" menu, because there are no active windows. This
|
||||||
|
// means we have to handle it here.
|
||||||
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
|
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
|
||||||
if ([currEvent type] == NSKeyDown) {
|
if ([currEvent type] == NSKeyDown) {
|
||||||
NSString *menuKey = [sender keyEquivalent];
|
NSString *menuKey = [sender keyEquivalent];
|
||||||
|
@ -91,7 +97,8 @@ JNF_COCOA_ENTER(env);
|
||||||
eventKey = [NSString stringWithCharacters: &newChar length: 1];
|
eventKey = [NSString stringWithCharacters: &newChar length: 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([menuKey isEqualToString:eventKey]) {
|
NSWindow *keyWindow = [NSApp keyWindow];
|
||||||
|
if ([menuKey isEqualToString:eventKey] && keyWindow != nil) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -31,11 +31,12 @@
|
||||||
@interface AWTStrike : NSObject {
|
@interface AWTStrike : NSObject {
|
||||||
@public
|
@public
|
||||||
AWTFont * fAWTFont;
|
AWTFont * fAWTFont;
|
||||||
CGFloat fSize;
|
CGFloat fSize;
|
||||||
JRSFontRenderingStyle fStyle;
|
JRSFontRenderingStyle fStyle;
|
||||||
jint fAAStyle;
|
jint fAAStyle;
|
||||||
|
|
||||||
CGAffineTransform fTx;
|
CGAffineTransform fTx;
|
||||||
|
CGAffineTransform fDevTx;
|
||||||
CGAffineTransform fAltTx; // alternate strike tx used for Sun2D
|
CGAffineTransform fAltTx; // alternate strike tx used for Sun2D
|
||||||
CGAffineTransform fFontTx;
|
CGAffineTransform fFontTx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -65,6 +65,7 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||||
invDevTx.b *= -1;
|
invDevTx.b *= -1;
|
||||||
invDevTx.c *= -1;
|
invDevTx.c *= -1;
|
||||||
fFontTx = CGAffineTransformConcat(CGAffineTransformConcat(tx, invDevTx), sInverseTX);
|
fFontTx = CGAffineTransformConcat(CGAffineTransformConcat(tx, invDevTx), sInverseTX);
|
||||||
|
fDevTx = CGAffineTransformInvert(invDevTx);
|
||||||
|
|
||||||
// the "font size" is the square root of the determinant of the matrix
|
// the "font size" is the square root of the determinant of the matrix
|
||||||
fSize = sqrt(abs(fFontTx.a * fFontTx.d - fFontTx.b * fFontTx.c));
|
fSize = sqrt(abs(fFontTx.a * fFontTx.d - fFontTx.b * fFontTx.c));
|
||||||
|
@ -148,7 +149,8 @@ Java_sun_font_CStrike_getNativeGlyphAdvance
|
||||||
{
|
{
|
||||||
CGSize advance;
|
CGSize advance;
|
||||||
JNF_COCOA_ENTER(env);
|
JNF_COCOA_ENTER(env);
|
||||||
AWTFont *awtFont = ((AWTStrike *)jlong_to_ptr(awtStrikePtr))->fAWTFont;
|
AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
|
||||||
|
AWTFont *awtFont = awtStrike->fAWTFont;
|
||||||
|
|
||||||
// negative glyph codes are really unicodes, which were placed there by the mapper
|
// negative glyph codes are really unicodes, which were placed there by the mapper
|
||||||
// to indicate we should use CoreText to substitute the character
|
// to indicate we should use CoreText to substitute the character
|
||||||
|
@ -156,6 +158,10 @@ JNF_COCOA_ENTER(env);
|
||||||
const CTFontRef fallback = CTS_CopyCTFallbackFontAndGlyphForJavaGlyphCode(awtFont, glyphCode, &glyph);
|
const CTFontRef fallback = CTS_CopyCTFallbackFontAndGlyphForJavaGlyphCode(awtFont, glyphCode, &glyph);
|
||||||
CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1);
|
CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1);
|
||||||
CFRelease(fallback);
|
CFRelease(fallback);
|
||||||
|
advance = CGSizeApplyAffineTransform(advance, awtStrike->fFontTx);
|
||||||
|
if (!JRSFontStyleUsesFractionalMetrics(awtStrike->fStyle)) {
|
||||||
|
advance.width = round(advance.width);
|
||||||
|
}
|
||||||
|
|
||||||
JNF_COCOA_EXIT(env);
|
JNF_COCOA_EXIT(env);
|
||||||
return advance.width;
|
return advance.width;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -455,6 +455,7 @@ CGGI_ClearCanvas(CGGI_GlyphCanvas *canvas, GlyphInfo *info)
|
||||||
#define CGGI_GLYPH_BBOX_PADDING 2.0f
|
#define CGGI_GLYPH_BBOX_PADDING 2.0f
|
||||||
static inline GlyphInfo *
|
static inline GlyphInfo *
|
||||||
CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
||||||
|
const AWTStrike *strike,
|
||||||
const CGGI_RenderingMode *mode)
|
const CGGI_RenderingMode *mode)
|
||||||
{
|
{
|
||||||
size_t pixelSize = mode->glyphDescriptor->pixelSize;
|
size_t pixelSize = mode->glyphDescriptor->pixelSize;
|
||||||
|
@ -477,6 +478,12 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
||||||
width = 1;
|
width = 1;
|
||||||
height = 1;
|
height = 1;
|
||||||
}
|
}
|
||||||
|
advance = CGSizeApplyAffineTransform(advance, strike->fFontTx);
|
||||||
|
if (!JRSFontStyleUsesFractionalMetrics(strike->fStyle)) {
|
||||||
|
advance.width = round(advance.width);
|
||||||
|
advance.height = round(advance.height);
|
||||||
|
}
|
||||||
|
advance = CGSizeApplyAffineTransform(advance, strike->fDevTx);
|
||||||
|
|
||||||
#ifdef USE_IMAGE_ALIGNED_MEMORY
|
#ifdef USE_IMAGE_ALIGNED_MEMORY
|
||||||
// create separate memory
|
// create separate memory
|
||||||
|
@ -564,10 +571,10 @@ CGGI_CreateImageForUnicode
|
||||||
JRSFontGetBoundingBoxesForGlyphsAndStyle(fallback, &tx, style, &glyph, 1, &bbox);
|
JRSFontGetBoundingBoxesForGlyphsAndStyle(fallback, &tx, style, &glyph, 1, &bbox);
|
||||||
|
|
||||||
CGSize advance;
|
CGSize advance;
|
||||||
JRSFontGetAdvancesForGlyphsAndStyle(fallback, &tx, strike->fStyle, &glyph, 1, &advance);
|
CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1);
|
||||||
|
|
||||||
// create the Sun2D GlyphInfo we are going to strike into
|
// create the Sun2D GlyphInfo we are going to strike into
|
||||||
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, mode);
|
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mode);
|
||||||
|
|
||||||
// fix the context size, just in case the substituted character is unexpectedly large
|
// fix the context size, just in case the substituted character is unexpectedly large
|
||||||
CGGI_SizeCanvas(canvas, info->width, info->height, mode->cgFontMode);
|
CGGI_SizeCanvas(canvas, info->width, info->height, mode->cgFontMode);
|
||||||
|
@ -715,7 +722,7 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
|
||||||
JRSFontRenderingStyle bboxCGMode = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle);
|
JRSFontRenderingStyle bboxCGMode = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle);
|
||||||
|
|
||||||
JRSFontGetBoundingBoxesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, bboxCGMode, glyphs, len, bboxes);
|
JRSFontGetBoundingBoxesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, bboxCGMode, glyphs, len, bboxes);
|
||||||
JRSFontGetAdvancesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, strike->fStyle, glyphs, len, advances);
|
CTFontGetAdvancesForGlyphs((CTFontRef)font->fFont, kCTFontDefaultOrientation, glyphs, advances, len);
|
||||||
|
|
||||||
size_t maxWidth = 1;
|
size_t maxWidth = 1;
|
||||||
size_t maxHeight = 1;
|
size_t maxHeight = 1;
|
||||||
|
@ -732,7 +739,7 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
|
||||||
CGSize advance = advances[i];
|
CGSize advance = advances[i];
|
||||||
CGRect bbox = bboxes[i];
|
CGRect bbox = bboxes[i];
|
||||||
|
|
||||||
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, mode);
|
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mode);
|
||||||
|
|
||||||
if (maxWidth < glyphInfo->width) maxWidth = glyphInfo->width;
|
if (maxWidth < glyphInfo->width) maxWidth = glyphInfo->width;
|
||||||
if (maxHeight < glyphInfo->height) maxHeight = glyphInfo->height;
|
if (maxHeight < glyphInfo->height) maxHeight = glyphInfo->height;
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
# Refer to the note in basic.properties for a description as to what
|
# Refer to the note in basic.properties for a description as to what
|
||||||
# the mnemonics correspond to and how to calculate them.
|
# the mnemonics correspond to and how to calculate them.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# GTK specific properties
|
# GTK specific properties
|
||||||
|
|
||||||
# GTK color chooser properties:
|
# GTK color chooser properties:
|
||||||
GTKColorChooserPanel.textAndMnemonic=>K Color Chooser
|
GTKColorChooserPanel.textAndMnemonic=>K Color Chooser
|
||||||
# mnemonic as a VK_ constant
|
# mnemonic as a VK_ constant
|
||||||
|
|
||||||
GTKColorChooserPanel.hue.textAndMnemonic=&Hue:
|
GTKColorChooserPanel.hue.textAndMnemonic=&Hue:
|
||||||
|
|
||||||
GTKColorChooserPanel.red.textAndMnemonic=R&ed:
|
GTKColorChooserPanel.red.textAndMnemonic=R&ed:
|
||||||
|
|
||||||
GTKColorChooserPanel.saturation.textAndMnemonic=&Saturation:
|
GTKColorChooserPanel.saturation.textAndMnemonic=&Saturation:
|
||||||
|
|
||||||
GTKColorChooserPanel.green.textAndMnemonic=&Green:
|
GTKColorChooserPanel.green.textAndMnemonic=&Green:
|
||||||
|
|
||||||
GTKColorChooserPanel.value.textAndMnemonic=&Value:
|
GTKColorChooserPanel.value.textAndMnemonic=&Value:
|
||||||
|
|
||||||
GTKColorChooserPanel.blue.textAndMnemonic=&Blue:
|
GTKColorChooserPanel.blue.textAndMnemonic=&Blue:
|
||||||
|
|
||||||
GTKColorChooserPanel.color.textAndMnemonic=Color &Name:
|
GTKColorChooserPanel.color.textAndMnemonic=Color &Name:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############ FILE CHOOSER STRINGS #############
|
############ FILE CHOOSER STRINGS #############
|
||||||
|
|
||||||
FileChooser.acceptAllFileFilter.textAndMnemonic=All Files
|
FileChooser.acceptAllFileFilter.textAndMnemonic=All Files
|
||||||
FileChooser.newFolderButton.textAndMnemonic=&New Folder
|
FileChooser.newFolderButton.textAndMnemonic=&New Folder
|
||||||
FileChooser.newFolderDialog.textAndMnemonic=Folder name:
|
FileChooser.newFolderDialog.textAndMnemonic=Folder name:
|
||||||
FileChooser.newFolderNoDirectoryErrorTitle.textAndMnemonic=Error
|
FileChooser.newFolderNoDirectoryErrorTitle.textAndMnemonic=Error
|
||||||
FileChooser.newFolderNoDirectoryError.textAndMnemonic=Error creating directory "{0}": No such file or directory
|
FileChooser.newFolderNoDirectoryError.textAndMnemonic=Error creating directory "{0}": No such file or directory
|
||||||
FileChooser.deleteFileButton.textAndMnemonic=De&lete File
|
FileChooser.deleteFileButton.textAndMnemonic=De&lete File
|
||||||
FileChooser.renameFileButton.textAndMnemonic=&Rename File
|
FileChooser.renameFileButton.textAndMnemonic=&Rename File
|
||||||
FileChooser.cancelButton.textAndMnemonic=&Cancel
|
FileChooser.cancelButton.textAndMnemonic=&Cancel
|
||||||
FileChooser.saveButton.textAndMnemonic=&OK
|
FileChooser.saveButton.textAndMnemonic=&OK
|
||||||
FileChooser.openButton.textAndMnemonic=&OK
|
FileChooser.openButton.textAndMnemonic=&OK
|
||||||
FileChooser.saveDialogTitle.textAndMnemonic=Save
|
FileChooser.saveDialogTitle.textAndMnemonic=Save
|
||||||
FileChooser.openDialogTitle.textAndMnemonic=Open
|
FileChooser.openDialogTitle.textAndMnemonic=Open
|
||||||
FileChooser.pathLabel.textAndMnemonic=&Selection:
|
FileChooser.pathLabel.textAndMnemonic=&Selection:
|
||||||
FileChooser.filterLabel.textAndMnemonic=Filter:
|
FileChooser.filterLabel.textAndMnemonic=Filter:
|
||||||
FileChooser.foldersLabel.textAndMnemonic=Fol&ders
|
FileChooser.foldersLabel.textAndMnemonic=Fol&ders
|
||||||
FileChooser.filesLabel.textAndMnemonic=&Files
|
FileChooser.filesLabel.textAndMnemonic=&Files
|
||||||
|
|
||||||
FileChooser.cancelButtonToolTip.textAndMnemonic=Abort file chooser dialog.
|
FileChooser.cancelButtonToolTip.textAndMnemonic=Abort file chooser dialog.
|
||||||
FileChooser.saveButtonToolTip.textAndMnemonic=Save selected file.
|
FileChooser.saveButtonToolTip.textAndMnemonic=Save selected file.
|
||||||
FileChooser.openButtonToolTip.textAndMnemonic=Open selected file.
|
FileChooser.openButtonToolTip.textAndMnemonic=Open selected file.
|
||||||
|
|
||||||
FileChooser.renameFileDialog.textAndMnemonic=Rename file "{0}" to
|
FileChooser.renameFileDialog.textAndMnemonic=Rename file "{0}" to
|
||||||
FileChooser.renameFileError.titleAndMnemonic=Error
|
FileChooser.renameFileError.titleAndMnemonic=Error
|
||||||
FileChooser.renameFileError.textAndMnemonic=Error renaming file "{0}" to "{1}"
|
FileChooser.renameFileError.textAndMnemonic=Error renaming file "{0}" to "{1}"
|
||||||
|
|
||||||
|
|
|
@ -499,7 +499,8 @@ public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||||
|
|
||||||
public void setItem(Object item) {
|
public void setItem(Object item) {
|
||||||
super.setItem(item);
|
super.setItem(item);
|
||||||
if (editor.hasFocus()) {
|
Object focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||||
|
if ((focus == editor) || (focus == editor.getParent())) {
|
||||||
editor.selectAll();
|
editor.selectAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -47,6 +47,10 @@ import javax.security.auth.PrivateCredentialPermission;
|
||||||
|
|
||||||
import sun.security.util.PropertyExpander;
|
import sun.security.util.PropertyExpander;
|
||||||
|
|
||||||
|
import sun.security.provider.PolicyParser.PrincipalEntry;
|
||||||
|
import sun.security.provider.PolicyParser.GrantEntry;
|
||||||
|
import sun.security.provider.PolicyParser.PermissionEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a default implementation for
|
* This class represents a default implementation for
|
||||||
* <code>javax.security.auth.Policy</code>.
|
* <code>javax.security.auth.Policy</code>.
|
||||||
|
@ -469,7 +473,8 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
* @param policyFile the policy Reader object.
|
* @param policyFile the policy Reader object.
|
||||||
*/
|
*/
|
||||||
private void init(URL policy) {
|
private void init(URL policy) {
|
||||||
PolicyParser pp = new PolicyParser(expandProperties);
|
sun.security.provider.PolicyParser pp =
|
||||||
|
new sun.security.provider.PolicyParser(expandProperties);
|
||||||
try {
|
try {
|
||||||
InputStreamReader isr
|
InputStreamReader isr
|
||||||
= new InputStreamReader(getInputStream(policy));
|
= new InputStreamReader(getInputStream(policy));
|
||||||
|
@ -477,12 +482,12 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
isr.close();
|
isr.close();
|
||||||
KeyStore keyStore = initKeyStore(policy, pp.getKeyStoreUrl(),
|
KeyStore keyStore = initKeyStore(policy, pp.getKeyStoreUrl(),
|
||||||
pp.getKeyStoreType());
|
pp.getKeyStoreType());
|
||||||
Enumeration<PolicyParser.GrantEntry> enum_ = pp.grantElements();
|
Enumeration<GrantEntry> enum_ = pp.grantElements();
|
||||||
while (enum_.hasMoreElements()) {
|
while (enum_.hasMoreElements()) {
|
||||||
PolicyParser.GrantEntry ge = enum_.nextElement();
|
GrantEntry ge = enum_.nextElement();
|
||||||
addGrantEntry(ge, keyStore);
|
addGrantEntry(ge, keyStore);
|
||||||
}
|
}
|
||||||
} catch (PolicyParser.ParsingException pe) {
|
} catch (sun.security.provider.PolicyParser.ParsingException pe) {
|
||||||
System.err.println(AUTH_POLICY +
|
System.err.println(AUTH_POLICY +
|
||||||
rb.getString(".error.parsing.") + policy);
|
rb.getString(".error.parsing.") + policy);
|
||||||
System.err.println(AUTH_POLICY +
|
System.err.println(AUTH_POLICY +
|
||||||
|
@ -521,8 +526,8 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
*
|
*
|
||||||
* @return null if signedBy alias is not recognized
|
* @return null if signedBy alias is not recognized
|
||||||
*/
|
*/
|
||||||
CodeSource getCodeSource(PolicyParser.GrantEntry ge, KeyStore keyStore)
|
CodeSource getCodeSource(GrantEntry ge, KeyStore keyStore)
|
||||||
throws java.net.MalformedURLException
|
throws java.net.MalformedURLException
|
||||||
{
|
{
|
||||||
Certificate[] certs = null;
|
Certificate[] certs = null;
|
||||||
if (ge.signedBy != null) {
|
if (ge.signedBy != null) {
|
||||||
|
@ -559,20 +564,18 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
/**
|
/**
|
||||||
* Add one policy entry to the vector.
|
* Add one policy entry to the vector.
|
||||||
*/
|
*/
|
||||||
private void addGrantEntry(PolicyParser.GrantEntry ge,
|
private void addGrantEntry(GrantEntry ge, KeyStore keyStore) {
|
||||||
KeyStore keyStore) {
|
|
||||||
|
|
||||||
if (debug != null) {
|
if (debug != null) {
|
||||||
debug.println("Adding policy entry: ");
|
debug.println("Adding policy entry: ");
|
||||||
debug.println(" signedBy " + ge.signedBy);
|
debug.println(" signedBy " + ge.signedBy);
|
||||||
debug.println(" codeBase " + ge.codeBase);
|
debug.println(" codeBase " + ge.codeBase);
|
||||||
if (ge.principals != null && ge.principals.size() > 0) {
|
if (ge.principals != null && ge.principals.size() > 0) {
|
||||||
ListIterator<PolicyParser.PrincipalEntry> li =
|
ListIterator<PrincipalEntry> li = ge.principals.listIterator();
|
||||||
ge.principals.listIterator();
|
|
||||||
while (li.hasNext()) {
|
while (li.hasNext()) {
|
||||||
PolicyParser.PrincipalEntry pppe = li.next();
|
PrincipalEntry pppe = li.next();
|
||||||
debug.println(" " + pppe.principalClass +
|
debug.println(" " + pppe.getPrincipalClass() +
|
||||||
" " + pppe.principalName);
|
" " + pppe.getPrincipalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug.println();
|
debug.println();
|
||||||
|
@ -584,10 +587,9 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
if (codesource == null) return;
|
if (codesource == null) return;
|
||||||
|
|
||||||
PolicyEntry entry = new PolicyEntry(codesource);
|
PolicyEntry entry = new PolicyEntry(codesource);
|
||||||
Enumeration<PolicyParser.PermissionEntry> enum_ =
|
Enumeration<PermissionEntry> enum_ = ge.permissionElements();
|
||||||
ge.permissionElements();
|
|
||||||
while (enum_.hasMoreElements()) {
|
while (enum_.hasMoreElements()) {
|
||||||
PolicyParser.PermissionEntry pe = enum_.nextElement();
|
PermissionEntry pe = enum_.nextElement();
|
||||||
try {
|
try {
|
||||||
// XXX special case PrivateCredentialPermission-SELF
|
// XXX special case PrivateCredentialPermission-SELF
|
||||||
Permission perm;
|
Permission perm;
|
||||||
|
@ -998,11 +1000,11 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListIterator<PolicyParser.PrincipalEntry> pli =
|
ListIterator<PrincipalEntry> pli =
|
||||||
scs.getPrincipals().listIterator();
|
scs.getPrincipals().listIterator();
|
||||||
while (pli.hasNext()) {
|
while (pli.hasNext()) {
|
||||||
|
|
||||||
PolicyParser.PrincipalEntry principal = pli.next();
|
PrincipalEntry principal = pli.next();
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
// if the Policy entry's Principal does not contain a
|
// if the Policy entry's Principal does not contain a
|
||||||
|
@ -1050,30 +1052,29 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
* if (y == 1), it's the principal name.
|
* if (y == 1), it's the principal name.
|
||||||
*/
|
*/
|
||||||
private String[][] getPrincipalInfo
|
private String[][] getPrincipalInfo
|
||||||
(PolicyParser.PrincipalEntry principal,
|
(PrincipalEntry principal, final CodeSource accCs) {
|
||||||
final CodeSource accCs) {
|
|
||||||
|
|
||||||
// there are 3 possibilities:
|
// there are 3 possibilities:
|
||||||
// 1) the entry's Principal class and name are not wildcarded
|
// 1) the entry's Principal class and name are not wildcarded
|
||||||
// 2) the entry's Principal name is wildcarded only
|
// 2) the entry's Principal name is wildcarded only
|
||||||
// 3) the entry's Principal class and name are wildcarded
|
// 3) the entry's Principal class and name are wildcarded
|
||||||
|
|
||||||
if (!principal.principalClass.equals
|
if (!principal.getPrincipalClass().equals
|
||||||
(PolicyParser.PrincipalEntry.WILDCARD_CLASS) &&
|
(PrincipalEntry.WILDCARD_CLASS) &&
|
||||||
!principal.principalName.equals
|
!principal.getPrincipalName().equals
|
||||||
(PolicyParser.PrincipalEntry.WILDCARD_NAME)) {
|
(PrincipalEntry.WILDCARD_NAME)) {
|
||||||
|
|
||||||
// build a PrivateCredentialPermission for the principal
|
// build a PrivateCredentialPermission for the principal
|
||||||
// from the Policy entry
|
// from the Policy entry
|
||||||
String[][] info = new String[1][2];
|
String[][] info = new String[1][2];
|
||||||
info[0][0] = principal.principalClass;
|
info[0][0] = principal.getPrincipalClass();
|
||||||
info[0][1] = principal.principalName;
|
info[0][1] = principal.getPrincipalName();
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
} else if (!principal.principalClass.equals
|
} else if (!principal.getPrincipalClass().equals
|
||||||
(PolicyParser.PrincipalEntry.WILDCARD_CLASS) &&
|
(PrincipalEntry.WILDCARD_CLASS) &&
|
||||||
principal.principalName.equals
|
principal.getPrincipalName().equals
|
||||||
(PolicyParser.PrincipalEntry.WILDCARD_NAME)) {
|
(PrincipalEntry.WILDCARD_NAME)) {
|
||||||
|
|
||||||
// build a PrivateCredentialPermission for all
|
// build a PrivateCredentialPermission for all
|
||||||
// the Subject's principals that are instances of principalClass
|
// the Subject's principals that are instances of principalClass
|
||||||
|
@ -1088,7 +1089,7 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
// If it doesn't, we should stop here with a ClassCastException.
|
// If it doesn't, we should stop here with a ClassCastException.
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends Principal> pClass = (Class<? extends Principal>)
|
Class<? extends Principal> pClass = (Class<? extends Principal>)
|
||||||
Class.forName(principal.principalClass, false,
|
Class.forName(principal.getPrincipalClass(), false,
|
||||||
ClassLoader.getSystemClassLoader());
|
ClassLoader.getSystemClassLoader());
|
||||||
principalSet = scs.getSubject().getPrincipals(pClass);
|
principalSet = scs.getSubject().getPrincipals(pClass);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1387,6 +1388,7 @@ public class PolicyFile extends javax.security.auth.Policy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
class PolicyPermissions extends PermissionCollection {
|
class PolicyPermissions extends PermissionCollection {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1954188373270545523L;
|
private static final long serialVersionUID = -1954188373270545523L;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -33,6 +33,7 @@ import java.security.cert.Certificate;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
import javax.security.auth.Subject;
|
import javax.security.auth.Subject;
|
||||||
|
import sun.security.provider.PolicyParser.PrincipalEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> This <code>SubjectCodeSource</code> class contains
|
* <p> This <code>SubjectCodeSource</code> class contains
|
||||||
|
@ -57,7 +58,7 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
});
|
});
|
||||||
|
|
||||||
private Subject subject;
|
private Subject subject;
|
||||||
private LinkedList<PolicyParser.PrincipalEntry> principals;
|
private LinkedList<PrincipalEntry> principals;
|
||||||
private static final Class[] PARAMS = { String.class };
|
private static final Class[] PARAMS = { String.class };
|
||||||
private static final sun.security.util.Debug debug =
|
private static final sun.security.util.Debug debug =
|
||||||
sun.security.util.Debug.getInstance("auth", "\t[Auth Access]");
|
sun.security.util.Debug.getInstance("auth", "\t[Auth Access]");
|
||||||
|
@ -87,14 +88,14 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
* <code>SubjectCodeSource</code> <p>
|
* <code>SubjectCodeSource</code> <p>
|
||||||
*/
|
*/
|
||||||
SubjectCodeSource(Subject subject,
|
SubjectCodeSource(Subject subject,
|
||||||
LinkedList<PolicyParser.PrincipalEntry> principals,
|
LinkedList<PrincipalEntry> principals,
|
||||||
URL url, Certificate[] certs) {
|
URL url, Certificate[] certs) {
|
||||||
|
|
||||||
super(url, certs);
|
super(url, certs);
|
||||||
this.subject = subject;
|
this.subject = subject;
|
||||||
this.principals = (principals == null ?
|
this.principals = (principals == null ?
|
||||||
new LinkedList<PolicyParser.PrincipalEntry>() :
|
new LinkedList<PrincipalEntry>() :
|
||||||
new LinkedList<PolicyParser.PrincipalEntry>(principals));
|
new LinkedList<PrincipalEntry>(principals));
|
||||||
sysClassLoader = java.security.AccessController.doPrivileged
|
sysClassLoader = java.security.AccessController.doPrivileged
|
||||||
(new java.security.PrivilegedAction<ClassLoader>() {
|
(new java.security.PrivilegedAction<ClassLoader>() {
|
||||||
public ClassLoader run() {
|
public ClassLoader run() {
|
||||||
|
@ -114,7 +115,7 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
* <code>SubjectCodeSource</code> as a <code>LinkedList</code>
|
* <code>SubjectCodeSource</code> as a <code>LinkedList</code>
|
||||||
* of <code>PolicyParser.PrincipalEntry</code> objects.
|
* of <code>PolicyParser.PrincipalEntry</code> objects.
|
||||||
*/
|
*/
|
||||||
LinkedList<PolicyParser.PrincipalEntry> getPrincipals() {
|
LinkedList<PrincipalEntry> getPrincipals() {
|
||||||
return principals;
|
return principals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +168,7 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
*/
|
*/
|
||||||
public boolean implies(CodeSource codesource) {
|
public boolean implies(CodeSource codesource) {
|
||||||
|
|
||||||
LinkedList<PolicyParser.PrincipalEntry> subjectList = null;
|
LinkedList<PrincipalEntry> subjectList = null;
|
||||||
|
|
||||||
if (codesource == null ||
|
if (codesource == null ||
|
||||||
!(codesource instanceof SubjectCodeSource) ||
|
!(codesource instanceof SubjectCodeSource) ||
|
||||||
|
@ -197,20 +198,19 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListIterator<PolicyParser.PrincipalEntry> li =
|
ListIterator<PrincipalEntry> li = this.principals.listIterator(0);
|
||||||
this.principals.listIterator(0);
|
|
||||||
while (li.hasNext()) {
|
while (li.hasNext()) {
|
||||||
PolicyParser.PrincipalEntry pppe = li.next();
|
PrincipalEntry pppe = li.next();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// handle PrincipalComparators
|
// handle PrincipalComparators
|
||||||
|
|
||||||
Class<?> principalComparator = Class.forName(
|
Class<?> principalComparator = Class.forName(
|
||||||
pppe.principalClass, true, sysClassLoader);
|
pppe.getPrincipalClass(), true, sysClassLoader);
|
||||||
Constructor<?> c = principalComparator.getConstructor(PARAMS);
|
Constructor<?> c = principalComparator.getConstructor(PARAMS);
|
||||||
PrincipalComparator pc =
|
PrincipalComparator pc =
|
||||||
(PrincipalComparator)c.newInstance
|
(PrincipalComparator)c.newInstance
|
||||||
(new Object[] { pppe.principalName });
|
(new Object[] { pppe.getPrincipalName() });
|
||||||
|
|
||||||
if (!pc.implies(that.getSubject())) {
|
if (!pc.implies(that.getSubject())) {
|
||||||
if (debug != null)
|
if (debug != null)
|
||||||
|
@ -236,11 +236,10 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
Iterator<Principal> i =
|
Iterator<Principal> i =
|
||||||
that.getSubject().getPrincipals().iterator();
|
that.getSubject().getPrincipals().iterator();
|
||||||
|
|
||||||
subjectList = new LinkedList<PolicyParser.PrincipalEntry>();
|
subjectList = new LinkedList<PrincipalEntry>();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Principal p = i.next();
|
Principal p = i.next();
|
||||||
PolicyParser.PrincipalEntry spppe =
|
PrincipalEntry spppe = new PrincipalEntry
|
||||||
new PolicyParser.PrincipalEntry
|
|
||||||
(p.getClass().getName(), p.getName());
|
(p.getClass().getName(), p.getName());
|
||||||
subjectList.add(spppe);
|
subjectList.add(spppe);
|
||||||
}
|
}
|
||||||
|
@ -281,23 +280,19 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
* <i>pppe</i> argument.
|
* <i>pppe</i> argument.
|
||||||
*/
|
*/
|
||||||
private boolean subjectListImpliesPrincipalEntry(
|
private boolean subjectListImpliesPrincipalEntry(
|
||||||
LinkedList<PolicyParser.PrincipalEntry> subjectList,
|
LinkedList<PrincipalEntry> subjectList, PrincipalEntry pppe) {
|
||||||
PolicyParser.PrincipalEntry pppe) {
|
|
||||||
|
|
||||||
ListIterator<PolicyParser.PrincipalEntry> li =
|
ListIterator<PrincipalEntry> li = subjectList.listIterator(0);
|
||||||
subjectList.listIterator(0);
|
|
||||||
while (li.hasNext()) {
|
while (li.hasNext()) {
|
||||||
PolicyParser.PrincipalEntry listPppe = li.next();
|
PrincipalEntry listPppe = li.next();
|
||||||
|
|
||||||
if (pppe.principalClass.equals
|
if (pppe.getPrincipalClass().equals
|
||||||
(PolicyParser.PrincipalEntry.WILDCARD_CLASS) ||
|
(PrincipalEntry.WILDCARD_CLASS) ||
|
||||||
pppe.principalClass.equals
|
pppe.getPrincipalClass().equals(listPppe.getPrincipalClass()))
|
||||||
(listPppe.principalClass)) {
|
{
|
||||||
|
if (pppe.getPrincipalName().equals
|
||||||
if (pppe.principalName.equals
|
(PrincipalEntry.WILDCARD_NAME) ||
|
||||||
(PolicyParser.PrincipalEntry.WILDCARD_NAME) ||
|
pppe.getPrincipalName().equals(listPppe.getPrincipalName()))
|
||||||
pppe.principalName.equals
|
|
||||||
(listPppe.principalName))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,13 +385,12 @@ class SubjectCodeSource extends CodeSource implements java.io.Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (principals != null) {
|
if (principals != null) {
|
||||||
ListIterator<PolicyParser.PrincipalEntry> li =
|
ListIterator<PrincipalEntry> li = principals.listIterator();
|
||||||
principals.listIterator();
|
|
||||||
while (li.hasNext()) {
|
while (li.hasNext()) {
|
||||||
PolicyParser.PrincipalEntry pppe = li.next();
|
PrincipalEntry pppe = li.next();
|
||||||
returnMe = returnMe + rb.getString("NEWLINE") +
|
returnMe = returnMe + rb.getString("NEWLINE") +
|
||||||
pppe.principalClass + " " +
|
pppe.getPrincipalClass() + " " +
|
||||||
pppe.principalName;
|
pppe.getPrincipalName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnMe;
|
return returnMe;
|
||||||
|
|
|
@ -1,45 +1,45 @@
|
||||||
# This properties file is used to create a PropertyResourceBundle
|
# This properties file is used to create a PropertyResourceBundle
|
||||||
# It contains Locale specific strings used be the Synth Look and Feel.
|
# It contains Locale specific strings used be the Synth Look and Feel.
|
||||||
# Currently, the following components need this for support:
|
# Currently, the following components need this for support:
|
||||||
#
|
#
|
||||||
# FileChooser
|
# FileChooser
|
||||||
#
|
#
|
||||||
# When this file is read in, the strings are put into the
|
# When this file is read in, the strings are put into the
|
||||||
# defaults table. This is an implementation detail of the current
|
# defaults table. This is an implementation detail of the current
|
||||||
# workings of Swing. DO NOT DEPEND ON THIS.
|
# workings of Swing. DO NOT DEPEND ON THIS.
|
||||||
# This may change in future versions of Swing as we improve localization
|
# This may change in future versions of Swing as we improve localization
|
||||||
# support.
|
# support.
|
||||||
#
|
#
|
||||||
# Refer to the note in basic.properties for a description as to what
|
# Refer to the note in basic.properties for a description as to what
|
||||||
# the mnemonics correspond to and how to calculate them.
|
# the mnemonics correspond to and how to calculate them.
|
||||||
#
|
#
|
||||||
# @author Steve Wilson
|
# @author Steve Wilson
|
||||||
|
|
||||||
|
|
||||||
############ FILE CHOOSER STRINGS #############
|
############ FILE CHOOSER STRINGS #############
|
||||||
|
|
||||||
FileChooser.lookInLabel.textAndMnemonic=Look &In:
|
FileChooser.lookInLabel.textAndMnemonic=Look &In:
|
||||||
FileChooser.saveInLabel.textAndMnemonic=Save In:
|
FileChooser.saveInLabel.textAndMnemonic=Save In:
|
||||||
FileChooser.fileNameLabel.textAndMnemonic=File &Name:
|
FileChooser.fileNameLabel.textAndMnemonic=File &Name:
|
||||||
FileChooser.folderNameLabel.textAndMnemonic=Folder &Name:
|
FileChooser.folderNameLabel.textAndMnemonic=Folder &Name:
|
||||||
FileChooser.filesOfTypeLabel.textAndMnemonic=Files of &Type:
|
FileChooser.filesOfTypeLabel.textAndMnemonic=Files of &Type:
|
||||||
FileChooser.upFolderToolTip.textAndMnemonic=Up One Level
|
FileChooser.upFolderToolTip.textAndMnemonic=Up One Level
|
||||||
FileChooser.upFolderAccessibleName=Up
|
FileChooser.upFolderAccessibleName=Up
|
||||||
FileChooser.homeFolderToolTip.textAndMnemonic=Home
|
FileChooser.homeFolderToolTip.textAndMnemonic=Home
|
||||||
FileChooser.homeFolderAccessibleName=Home
|
FileChooser.homeFolderAccessibleName=Home
|
||||||
FileChooser.newFolderToolTip.textAndMnemonic=Create New Folder
|
FileChooser.newFolderToolTip.textAndMnemonic=Create New Folder
|
||||||
FileChooser.newFolderAccessibleName=New Folder
|
FileChooser.newFolderAccessibleName=New Folder
|
||||||
FileChooser.newFolderActionLabel.textAndMnemonic=New Folder
|
FileChooser.newFolderActionLabel.textAndMnemonic=New Folder
|
||||||
FileChooser.listViewButtonToolTip.textAndMnemonic=List
|
FileChooser.listViewButtonToolTip.textAndMnemonic=List
|
||||||
FileChooser.listViewButtonAccessibleName=List
|
FileChooser.listViewButtonAccessibleName=List
|
||||||
FileChooser.listViewActionLabel.textAndMnemonic=List
|
FileChooser.listViewActionLabel.textAndMnemonic=List
|
||||||
FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
|
FileChooser.detailsViewButtonToolTip.textAndMnemonic=Details
|
||||||
FileChooser.detailsViewButtonAccessibleName=Details
|
FileChooser.detailsViewButtonAccessibleName=Details
|
||||||
FileChooser.detailsViewActionLabel.textAndMnemonic=Details
|
FileChooser.detailsViewActionLabel.textAndMnemonic=Details
|
||||||
FileChooser.refreshActionLabel.textAndMnemonic=Refresh
|
FileChooser.refreshActionLabel.textAndMnemonic=Refresh
|
||||||
FileChooser.viewMenuLabel.textAndMnemonic=View
|
FileChooser.viewMenuLabel.textAndMnemonic=View
|
||||||
FileChooser.fileNameHeader.textAndMnemonic=Name
|
FileChooser.fileNameHeader.textAndMnemonic=Name
|
||||||
FileChooser.fileSizeHeader.textAndMnemonic=Size
|
FileChooser.fileSizeHeader.textAndMnemonic=Size
|
||||||
FileChooser.fileTypeHeader.textAndMnemonic=Type
|
FileChooser.fileTypeHeader.textAndMnemonic=Type
|
||||||
FileChooser.fileDateHeader.textAndMnemonic=Modified
|
FileChooser.fileDateHeader.textAndMnemonic=Modified
|
||||||
FileChooser.fileAttrHeader.textAndMnemonic=Attributes
|
FileChooser.fileAttrHeader.textAndMnemonic=Attributes
|
||||||
|
|
|
@ -151,7 +151,7 @@ function JavaClassProto() {
|
||||||
while (tmp != null) {
|
while (tmp != null) {
|
||||||
res[res.length] = tmp;
|
res[res.length] = tmp;
|
||||||
tmp = tmp.superclass;
|
tmp = tmp.superclass;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,16 +263,19 @@ function wrapJavaObject(thing) {
|
||||||
|
|
||||||
if (name == 'class') {
|
if (name == 'class') {
|
||||||
return wrapJavaValue(instance.clazz);
|
return wrapJavaValue(instance.clazz);
|
||||||
} else if (name == 'toString') {
|
|
||||||
return function() {
|
|
||||||
return instance.toString();
|
|
||||||
}
|
|
||||||
} else if (name == 'wrapped-object') {
|
} else if (name == 'wrapped-object') {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
},
|
||||||
|
__call__: function(name) {
|
||||||
|
if (name == 'toString') {
|
||||||
|
return instance.toString();
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +300,7 @@ function wrapJavaObject(thing) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return theJavaClassProto[name] != undefined;
|
return false;
|
||||||
},
|
},
|
||||||
__get__ : function(name) {
|
__get__ : function(name) {
|
||||||
for (var i in fields) {
|
for (var i in fields) {
|
||||||
|
@ -305,7 +308,7 @@ function wrapJavaObject(thing) {
|
||||||
return wrapJavaValue(fields[i].value);
|
return wrapJavaValue(fields[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return theJavaClassProto[name];
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +325,12 @@ function wrapJavaObject(thing) {
|
||||||
this.name = jclass.name;
|
this.name = jclass.name;
|
||||||
this.fields = jclass.fields;
|
this.fields = jclass.fields;
|
||||||
this['wrapped-object'] = jclass;
|
this['wrapped-object'] = jclass;
|
||||||
this.__proto__ = this.statics;
|
}
|
||||||
|
|
||||||
|
for (var i in theJavaClassProto) {
|
||||||
|
if (typeof theJavaClassProto[i] == 'function') {
|
||||||
|
JavaClassWrapper.prototype[i] = theJavaClassProto[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns wrapper for Java object arrays
|
// returns wrapper for Java object arrays
|
||||||
|
@ -334,32 +342,35 @@ function wrapJavaObject(thing) {
|
||||||
__getIds__ : function() {
|
__getIds__ : function() {
|
||||||
var res = new Array(elements.length);
|
var res = new Array(elements.length);
|
||||||
for (var i = 0; i < elements.length; i++) {
|
for (var i = 0; i < elements.length; i++) {
|
||||||
res[i] = i;
|
res[i] = String(i);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
__has__: function(name) {
|
__has__: function(name) {
|
||||||
return (typeof(name) == 'number' &&
|
return (name >= 0 && name < elements.length) ||
|
||||||
name >= 0 && name < elements.length) ||
|
|
||||||
name == 'length' || name == 'class' ||
|
name == 'length' || name == 'class' ||
|
||||||
name == 'toString' || name == 'wrapped-object';
|
name == 'toString' || name == 'wrapped-object';
|
||||||
},
|
},
|
||||||
__get__ : function(name) {
|
__get__ : function(name) {
|
||||||
if (typeof(name) == 'number' &&
|
if (name >= 0 && name < elements.length) {
|
||||||
name >= 0 && name < elements.length) {
|
|
||||||
return wrapJavaValue(elements[name]);
|
return wrapJavaValue(elements[name]);
|
||||||
} else if (name == 'length') {
|
} else if (name == 'length') {
|
||||||
return elements.length;
|
return elements.length;
|
||||||
} else if (name == 'class') {
|
} else if (name == 'class') {
|
||||||
return wrapJavaValue(array.clazz);
|
return wrapJavaValue(array.clazz);
|
||||||
} else if (name == 'toString') {
|
|
||||||
return function() { return array.toString(); }
|
|
||||||
} else if (name == 'wrapped-object') {
|
} else if (name == 'wrapped-object') {
|
||||||
return array;
|
return array;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
__call__: function(name) {
|
||||||
|
if (name == 'toString') {
|
||||||
|
return array.toString();
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,26 +384,22 @@ function wrapJavaObject(thing) {
|
||||||
__getIds__ : function() {
|
__getIds__ : function() {
|
||||||
var r = new Array(array.length);
|
var r = new Array(array.length);
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
r[i] = i;
|
r[i] = String(i);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
},
|
},
|
||||||
__has__: function(name) {
|
__has__: function(name) {
|
||||||
return (typeof(name) == 'number' &&
|
return (name >= 0 && name < array.length) ||
|
||||||
name >= 0 && name < array.length) ||
|
|
||||||
name == 'length' || name == 'class' ||
|
name == 'length' || name == 'class' ||
|
||||||
name == 'toString' || name == 'wrapped-object';
|
name == 'toString' || name == 'wrapped-object';
|
||||||
},
|
},
|
||||||
__get__: function(name) {
|
__get__: function(name) {
|
||||||
if (typeof(name) == 'number' &&
|
if (name >= 0 && name < array.length) {
|
||||||
name >= 0 && name < array.length) {
|
|
||||||
return elements[name];
|
return elements[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == 'length') {
|
if (name == 'length') {
|
||||||
return array.length;
|
return array.length;
|
||||||
} else if (name == 'toString') {
|
|
||||||
return function() { return array.valueString(true); }
|
|
||||||
} else if (name == 'wrapped-object') {
|
} else if (name == 'wrapped-object') {
|
||||||
return array;
|
return array;
|
||||||
} else if (name == 'class') {
|
} else if (name == 'class') {
|
||||||
|
@ -400,7 +407,14 @@ function wrapJavaObject(thing) {
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
__call__: function(name) {
|
||||||
|
if (name == 'toString') {
|
||||||
|
return array.valueString(true);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return javaObject(thing);
|
return javaObject(thing);
|
||||||
|
@ -673,34 +687,33 @@ function wrapHeapSnapshot(heap) {
|
||||||
__getIds__ : function() {
|
__getIds__ : function() {
|
||||||
var res = new Array(path.length);
|
var res = new Array(path.length);
|
||||||
for (var i = 0; i < path.length; i++) {
|
for (var i = 0; i < path.length; i++) {
|
||||||
res[i] = i;
|
res[i] = String(i);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
__has__ : function (name) {
|
__has__ : function (name) {
|
||||||
return (typeof(name) == 'number' &&
|
return (name >= 0 && name < path.length) ||
|
||||||
name >= 0 && name < path.length) ||
|
|
||||||
name == 'length' || name == 'toHtml' ||
|
name == 'length' || name == 'toHtml' ||
|
||||||
name == 'toString';
|
name == 'toString';
|
||||||
},
|
},
|
||||||
__get__ : function(name) {
|
__get__ : function(name) {
|
||||||
if (typeof(name) == 'number' &&
|
if (name >= 0 && name < path.length) {
|
||||||
name >= 0 && name < path.length) {
|
|
||||||
return path[name];
|
return path[name];
|
||||||
} else if (name == 'length') {
|
} else if (name == 'length') {
|
||||||
return path.length;
|
return path.length;
|
||||||
} else if (name == 'toHtml') {
|
|
||||||
return function() {
|
|
||||||
return computeDescription(true);
|
|
||||||
}
|
|
||||||
} else if (name == 'toString') {
|
|
||||||
return function() {
|
|
||||||
return computeDescription(false);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
__call__: function(name) {
|
||||||
|
if (name == 'toHtml') {
|
||||||
|
return computeDescription(true);
|
||||||
|
} else if (name == 'toString') {
|
||||||
|
return computeDescription(false);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,22 +1018,8 @@ function toHtml(obj) {
|
||||||
return "<a href='/object/" + id + "'>" +
|
return "<a href='/object/" + id + "'>" +
|
||||||
name + "@" + id + "</a>";
|
name + "@" + id + "</a>";
|
||||||
}
|
}
|
||||||
} else if ((typeof(obj) == 'object') || (obj instanceof JSAdapter)) {
|
} else if (obj instanceof Object) {
|
||||||
if (obj instanceof java.lang.Object) {
|
if (Array.isArray(obj)) {
|
||||||
// script wrapped Java object
|
|
||||||
obj = wrapIterator(obj);
|
|
||||||
// special case for enumeration
|
|
||||||
if (obj instanceof java.util.Enumeration) {
|
|
||||||
var res = "[ ";
|
|
||||||
while (obj.hasMoreElements()) {
|
|
||||||
res += toHtml(obj.nextElement()) + ", ";
|
|
||||||
}
|
|
||||||
res += "]";
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
} else if (obj instanceof Array) {
|
|
||||||
// script array
|
// script array
|
||||||
var res = "[ ";
|
var res = "[ ";
|
||||||
for (var i in obj) {
|
for (var i in obj) {
|
||||||
|
@ -1047,8 +1046,19 @@ function toHtml(obj) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// JavaScript primitive value
|
// a Java object
|
||||||
return obj;
|
obj = wrapIterator(obj);
|
||||||
|
// special case for enumeration
|
||||||
|
if (obj instanceof java.util.Enumeration) {
|
||||||
|
var res = "[ ";
|
||||||
|
while (obj.hasMoreElements()) {
|
||||||
|
res += toHtml(obj.nextElement()) + ", ";
|
||||||
|
}
|
||||||
|
res += "]";
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ bound to a JavaScript variable of the identifier name specified in <span class="
|
||||||
<li>select all Strings of length 100 or more
|
<li>select all Strings of length 100 or more
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select s from java.lang.String s where s.count >= 100
|
select s from java.lang.String s where s.value.length >= 100
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
<li>select all int arrays of length 256 or more
|
<li>select all int arrays of length 256 or more
|
||||||
|
@ -92,7 +92,7 @@ bound to a JavaScript variable of the identifier name specified in <span class="
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select s.value.toString() from java.lang.String s
|
select s.value.toString() from java.lang.String s
|
||||||
where /java/(s.value.toString())
|
where /java/.test(s.value.toString())
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
<li>show path value of all File objects
|
<li>show path value of all File objects
|
||||||
|
@ -219,7 +219,6 @@ Examples:
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select heap.findClass("java.lang.System").statics.props
|
select heap.findClass("java.lang.System").statics.props
|
||||||
select heap.findClass("java.lang.System").props
|
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
<li>get number of fields of java.lang.String class
|
<li>get number of fields of java.lang.String class
|
||||||
|
@ -237,7 +236,7 @@ Examples:
|
||||||
<li>select all classes that have name pattern java.net.*
|
<li>select all classes that have name pattern java.net.*
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select <a href="#filter">filter</a>(heap.classes(), "/java.net./(it.name)")
|
select <a href="#filter">filter</a>(heap.classes(), "/java.net./.test(it.name)")
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -536,7 +535,7 @@ refer to the following built-in variables.
|
||||||
Example: print number of classes that have specific name pattern
|
Example: print number of classes that have specific name pattern
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select count(<a href="#classes">heap.classes()</a>, "/java.io./(it.name)")
|
select count(<a href="#classes">heap.classes()</a>, "/java.io./.test(it.name)")
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
@ -559,14 +558,14 @@ Examples:
|
||||||
<li>show all classes that have java.io.* name pattern
|
<li>show all classes that have java.io.* name pattern
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select filter(<a href="#classes">heap.classes</a>(), "/java.io./(it.name)")
|
select filter(<a href="#classes">heap.classes</a>(), "/java.io./.test(it.name)")
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
<li> show all referrers of URL object where the referrer is not from
|
<li> show all referrers of URL object where the referrer is not from
|
||||||
java.net package
|
java.net package
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select filter(<a href="#referrers">referrers</a>(u), "! /java.net./(<a href="#classof">classof</a>(it).name)")
|
select filter(<a href="#referrers">referrers</a>(u), "! /java.net./.test(<a href="#classof">classof</a>(it).name)")
|
||||||
from java.net.URL u
|
from java.net.URL u
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -619,13 +618,13 @@ Examples:
|
||||||
<li>find the maximum length of any String instance
|
<li>find the maximum length of any String instance
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select max(map(heap.objects('java.lang.String', false), 'it.count'))
|
select max(map(heap.objects('java.lang.String', false), 'it.value.length'))
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
<li>find string instance that has the maximum length
|
<li>find string instance that has the maximum length
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select max(heap.objects('java.lang.String'), 'lhs.count > rhs.count')
|
select max(heap.objects('java.lang.String'), 'lhs.value.length > rhs.value.length')
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -775,7 +774,7 @@ and walk until parent is null using the callback function to map call.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<code>
|
<code>
|
||||||
select <a href="#map">map</a>(<a href="#filter">filter(<a href="#findClass">heap.findClass</a>('java.lang.System').props.table, 'it != null'),
|
select <a href="#map">map</a>(<a href="#filter">filter(<a href="#findClass">heap.findClass</a>('java.lang.System').statics.props.table, 'it != null'),
|
||||||
function (it) {
|
function (it) {
|
||||||
var res = "";
|
var res = "";
|
||||||
while (it != null) {
|
while (it != null) {
|
||||||
|
|
|
@ -332,7 +332,7 @@ function streamClose(stream) {
|
||||||
* @param str input from which script is loaded and evaluated
|
* @param str input from which script is loaded and evaluated
|
||||||
*/
|
*/
|
||||||
if (typeof(load) == 'undefined') {
|
if (typeof(load) == 'undefined') {
|
||||||
var load = function(str) {
|
this.load = function(str) {
|
||||||
var stream = inStream(str);
|
var stream = inStream(str);
|
||||||
var bstream = new BufferedInputStream(stream);
|
var bstream = new BufferedInputStream(stream);
|
||||||
var reader = new BufferedReader(new InputStreamReader(bstream));
|
var reader = new BufferedReader(new InputStreamReader(bstream));
|
||||||
|
@ -712,7 +712,7 @@ if (typeof(exit) == 'undefined') {
|
||||||
* @param exitCode integer code returned to OS shell.
|
* @param exitCode integer code returned to OS shell.
|
||||||
* optional, defaults to 0
|
* optional, defaults to 0
|
||||||
*/
|
*/
|
||||||
var exit = function (code) {
|
this.exit = function (code) {
|
||||||
if (code) {
|
if (code) {
|
||||||
java.lang.System.exit(code + 0);
|
java.lang.System.exit(code + 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -725,7 +725,7 @@ if (typeof(quit) == 'undefined') {
|
||||||
/**
|
/**
|
||||||
* synonym for exit
|
* synonym for exit
|
||||||
*/
|
*/
|
||||||
var quit = function (code) {
|
this.quit = function (code) {
|
||||||
exit(code);
|
exit(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -881,7 +881,7 @@ if (typeof(printf) == 'undefined') {
|
||||||
* @param format string to format the rest of the print items
|
* @param format string to format the rest of the print items
|
||||||
* @param args variadic argument list
|
* @param args variadic argument list
|
||||||
*/
|
*/
|
||||||
var printf = function (format, args/*, more args*/) {
|
this.printf = function (format, args/*, more args*/) {
|
||||||
var array = java.lang.reflect.Array.newInstance(java.lang.Object,
|
var array = java.lang.reflect.Array.newInstance(java.lang.Object,
|
||||||
arguments.length - 1);
|
arguments.length - 1);
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
@ -921,25 +921,7 @@ function read(prompt, multiline) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(println) == 'undefined') {
|
if (typeof(println) == 'undefined') {
|
||||||
var print = function(str, newline) {
|
// just synonym to print
|
||||||
if (typeof(str) == 'undefined') {
|
this.println = print;
|
||||||
str = 'undefined';
|
|
||||||
} else if (str == null) {
|
|
||||||
str = 'null';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(out instanceof java.io.PrintWriter)) {
|
|
||||||
out = new java.io.PrintWriter(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
out.print(String(str));
|
|
||||||
if (newline) {
|
|
||||||
out.print('\n');
|
|
||||||
}
|
|
||||||
out.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
var println = function(str) {
|
|
||||||
print(str, true);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. 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
|
||||||
|
@ -56,7 +56,7 @@ public interface AppletContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an <code>Image</code> object that can then be painted on
|
* Returns an <code>Image</code> object that can then be painted on
|
||||||
* the screen. The <code>url</code> argument<code> </code>that is
|
* the screen. The <code>url</code> argument that is
|
||||||
* passed as an argument must specify an absolute URL.
|
* passed as an argument must specify an absolute URL.
|
||||||
* <p>
|
* <p>
|
||||||
* This method always returns immediately, whether or not the image
|
* This method always returns immediately, whether or not the image
|
||||||
|
@ -157,7 +157,7 @@ public interface AppletContext {
|
||||||
* @param stream stream to be associated with the specified key. If this
|
* @param stream stream to be associated with the specified key. If this
|
||||||
* parameter is <code>null</code>, the specified key is removed
|
* parameter is <code>null</code>, the specified key is removed
|
||||||
* in this applet context.
|
* in this applet context.
|
||||||
* @throws <code>IOException</code> if the stream size exceeds a certain
|
* @throws IOException if the stream size exceeds a certain
|
||||||
* size limit. Size limit is decided by the implementor of this
|
* size limit. Size limit is decided by the implementor of this
|
||||||
* interface.
|
* interface.
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. 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,7 +26,7 @@ package java.awt;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals that an Absract Window Toolkit exception has occurred.
|
* Signals that an Abstract Window Toolkit exception has occurred.
|
||||||
*
|
*
|
||||||
* @author Arthur van Hoff
|
* @author Arthur van Hoff
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,7 +42,7 @@ import java.util.EventListener;
|
||||||
* Container events are provided for notification purposes ONLY;
|
* Container events are provided for notification purposes ONLY;
|
||||||
* The AWT will automatically handle add and remove operations
|
* The AWT will automatically handle add and remove operations
|
||||||
* internally so the program works properly regardless of
|
* internally so the program works properly regardless of
|
||||||
* whether the program registers a <code>ComponentListener</code> or not.
|
* whether the program registers a {@code ContainerListener} or not.
|
||||||
*
|
*
|
||||||
* @see ContainerAdapter
|
* @see ContainerAdapter
|
||||||
* @see ContainerEvent
|
* @see ContainerEvent
|
||||||
|
|
|
@ -55,7 +55,7 @@ import java.awt.Image;
|
||||||
* Alternatively, the contents of the back buffer can be copied, or
|
* Alternatively, the contents of the back buffer can be copied, or
|
||||||
* <i>blitted</i> forward in a chain instead of moving the video pointer.
|
* <i>blitted</i> forward in a chain instead of moving the video pointer.
|
||||||
* <p>
|
* <p>
|
||||||
* <pre>
|
* <pre>{@code
|
||||||
* Double buffering:
|
* Double buffering:
|
||||||
*
|
*
|
||||||
* *********** ***********
|
* *********** ***********
|
||||||
|
@ -72,7 +72,7 @@ import java.awt.Image;
|
||||||
* * * <------ * * <----- * *
|
* * * <------ * * <----- * *
|
||||||
* *********** *********** ***********
|
* *********** *********** ***********
|
||||||
*
|
*
|
||||||
* </pre>
|
* }</pre>
|
||||||
* <p>
|
* <p>
|
||||||
* Here is an example of how buffer strategies can be created and used:
|
* Here is an example of how buffer strategies can be created and used:
|
||||||
* <pre><code>
|
* <pre><code>
|
||||||
|
|
|
@ -602,12 +602,12 @@ public class BufferedImage extends java.awt.Image
|
||||||
* the raster has been premultiplied with alpha.
|
* the raster has been premultiplied with alpha.
|
||||||
* @param properties <code>Hashtable</code> of
|
* @param properties <code>Hashtable</code> of
|
||||||
* <code>String</code>/<code>Object</code> pairs.
|
* <code>String</code>/<code>Object</code> pairs.
|
||||||
* @exception <code>RasterFormatException</code> if the number and
|
* @exception RasterFormatException if the number and
|
||||||
* types of bands in the <code>SampleModel</code> of the
|
* types of bands in the <code>SampleModel</code> of the
|
||||||
* <code>Raster</code> do not match the number and types required by
|
* <code>Raster</code> do not match the number and types required by
|
||||||
* the <code>ColorModel</code> to represent its color and alpha
|
* the <code>ColorModel</code> to represent its color and alpha
|
||||||
* components.
|
* components.
|
||||||
* @exception <code>IllegalArgumentException</code> if
|
* @exception IllegalArgumentException if
|
||||||
* <code>raster</code> is incompatible with <code>cm</code>
|
* <code>raster</code> is incompatible with <code>cm</code>
|
||||||
* @see ColorModel
|
* @see ColorModel
|
||||||
* @see Raster
|
* @see Raster
|
||||||
|
@ -927,7 +927,7 @@ public class BufferedImage extends java.awt.Image
|
||||||
* each color component in the returned data when
|
* each color component in the returned data when
|
||||||
* using this method. With a specified coordinate (x, y) in the
|
* using this method. With a specified coordinate (x, y) in the
|
||||||
* image, the ARGB pixel can be accessed in this way:
|
* image, the ARGB pixel can be accessed in this way:
|
||||||
* </p>
|
* <p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)]; </pre>
|
* pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)]; </pre>
|
||||||
|
@ -1131,7 +1131,7 @@ public class BufferedImage extends java.awt.Image
|
||||||
* @return an {@link Object} that is the property referred to by the
|
* @return an {@link Object} that is the property referred to by the
|
||||||
* specified <code>name</code> or <code>null</code> if the
|
* specified <code>name</code> or <code>null</code> if the
|
||||||
* properties of this image are not yet known.
|
* properties of this image are not yet known.
|
||||||
* @throws <code>NullPointerException</code> if the property name is null.
|
* @throws NullPointerException if the property name is null.
|
||||||
* @see ImageObserver
|
* @see ImageObserver
|
||||||
* @see java.awt.Image#UndefinedProperty
|
* @see java.awt.Image#UndefinedProperty
|
||||||
*/
|
*/
|
||||||
|
@ -1144,7 +1144,7 @@ public class BufferedImage extends java.awt.Image
|
||||||
* @param name the property name
|
* @param name the property name
|
||||||
* @return an <code>Object</code> that is the property referred to by
|
* @return an <code>Object</code> that is the property referred to by
|
||||||
* the specified <code>name</code>.
|
* the specified <code>name</code>.
|
||||||
* @throws <code>NullPointerException</code> if the property name is null.
|
* @throws NullPointerException if the property name is null.
|
||||||
*/
|
*/
|
||||||
public Object getProperty(String name) {
|
public Object getProperty(String name) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
|
@ -1196,7 +1196,7 @@ public class BufferedImage extends java.awt.Image
|
||||||
* @param h the height of the specified rectangular region
|
* @param h the height of the specified rectangular region
|
||||||
* @return a <code>BufferedImage</code> that is the subimage of this
|
* @return a <code>BufferedImage</code> that is the subimage of this
|
||||||
* <code>BufferedImage</code>.
|
* <code>BufferedImage</code>.
|
||||||
* @exception <code>RasterFormatException</code> if the specified
|
* @exception RasterFormatException if the specified
|
||||||
* area is not contained within this <code>BufferedImage</code>.
|
* area is not contained within this <code>BufferedImage</code>.
|
||||||
*/
|
*/
|
||||||
public BufferedImage getSubimage (int x, int y, int w, int h) {
|
public BufferedImage getSubimage (int x, int y, int w, int h) {
|
||||||
|
@ -1388,7 +1388,7 @@ public class BufferedImage extends java.awt.Image
|
||||||
* @param tileY the y index of the requested tile in the tile array
|
* @param tileY the y index of the requested tile in the tile array
|
||||||
* @return a <code>Raster</code> that is the tile defined by the
|
* @return a <code>Raster</code> that is the tile defined by the
|
||||||
* arguments <code>tileX</code> and <code>tileY</code>.
|
* arguments <code>tileX</code> and <code>tileY</code>.
|
||||||
* @exception <code>ArrayIndexOutOfBoundsException</code> if both
|
* @exception ArrayIndexOutOfBoundsException if both
|
||||||
* <code>tileX</code> and <code>tileY</code> are not
|
* <code>tileX</code> and <code>tileY</code> are not
|
||||||
* equal to 0
|
* equal to 0
|
||||||
*/
|
*/
|
||||||
|
@ -1558,7 +1558,7 @@ public class BufferedImage extends java.awt.Image
|
||||||
* @return <code>true</code> if the tile specified by the specified
|
* @return <code>true</code> if the tile specified by the specified
|
||||||
* indices is checked out for writing; <code>false</code>
|
* indices is checked out for writing; <code>false</code>
|
||||||
* otherwise.
|
* otherwise.
|
||||||
* @exception <code>ArrayIndexOutOfBoundsException</code> if both
|
* @exception ArrayIndexOutOfBoundsException if both
|
||||||
* <code>tileX</code> and <code>tileY</code> are not equal
|
* <code>tileX</code> and <code>tileY</code> are not equal
|
||||||
* to 0
|
* to 0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class ByteLookupTable extends LookupTable {
|
||||||
* @exception ArrayIndexOutOfBoundsException if <code>src</code> is
|
* @exception ArrayIndexOutOfBoundsException if <code>src</code> is
|
||||||
* longer than <code>dst</code> or if for any element
|
* longer than <code>dst</code> or if for any element
|
||||||
* <code>i</code> of <code>src</code>,
|
* <code>i</code> of <code>src</code>,
|
||||||
* <code>(src[i]&0xff)-offset</code> is either less than
|
* {@code (src[i]&0xff)-offset} is either less than
|
||||||
* zero or greater than or equal to the length of the
|
* zero or greater than or equal to the length of the
|
||||||
* lookup table for any band.
|
* lookup table for any band.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -692,12 +692,12 @@ public abstract class ColorModel implements Transparency{
|
||||||
* <code>DataBuffer.TYPE_INT</code>.
|
* <code>DataBuffer.TYPE_INT</code>.
|
||||||
* @param inData an array of pixel values
|
* @param inData an array of pixel values
|
||||||
* @return the value of the green component of the specified pixel.
|
* @return the value of the green component of the specified pixel.
|
||||||
* @throws <code>ClassCastException</code> if <code>inData</code>
|
* @throws ClassCastException if <code>inData</code>
|
||||||
* is not a primitive array of type <code>transferType</code>
|
* is not a primitive array of type <code>transferType</code>
|
||||||
* @throws <code>ArrayIndexOutOfBoundsException</code> if
|
* @throws ArrayIndexOutOfBoundsException if
|
||||||
* <code>inData</code> is not large enough to hold a pixel value
|
* <code>inData</code> is not large enough to hold a pixel value
|
||||||
* for this <code>ColorModel</code>
|
* for this <code>ColorModel</code>
|
||||||
* @throws <code>UnsupportedOperationException</code> if this
|
* @throws UnsupportedOperationException if this
|
||||||
* <code>tranferType</code> is not supported by this
|
* <code>tranferType</code> is not supported by this
|
||||||
* <code>ColorModel</code>
|
* <code>ColorModel</code>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -642,12 +642,12 @@ public class DirectColorModel extends PackedColorModel {
|
||||||
* @param inData the specified pixel
|
* @param inData the specified pixel
|
||||||
* @return the alpha component of the specified pixel, scaled from
|
* @return the alpha component of the specified pixel, scaled from
|
||||||
* 0 to 255.
|
* 0 to 255.
|
||||||
* @exception <code>ClassCastException</code> if <code>inData</code>
|
* @exception ClassCastException if <code>inData</code>
|
||||||
* is not a primitive array of type <code>transferType</code>
|
* is not a primitive array of type <code>transferType</code>
|
||||||
* @exception <code>ArrayIndexOutOfBoundsException</code> if
|
* @exception ArrayIndexOutOfBoundsException if
|
||||||
* <code>inData</code> is not large enough to hold a pixel value
|
* <code>inData</code> is not large enough to hold a pixel value
|
||||||
* for this <code>ColorModel</code>
|
* for this <code>ColorModel</code>
|
||||||
* @exception <code>UnsupportedOperationException</code> if this
|
* @exception UnsupportedOperationException if this
|
||||||
* <code>tranferType</code> is not supported by this
|
* <code>tranferType</code> is not supported by this
|
||||||
* <code>ColorModel</code>
|
* <code>ColorModel</code>
|
||||||
*/
|
*/
|
||||||
|
@ -1055,7 +1055,7 @@ public class DirectColorModel extends PackedColorModel {
|
||||||
* begin retrieving the color and alpha components
|
* begin retrieving the color and alpha components
|
||||||
* @return an <code>int</code> pixel value in this
|
* @return an <code>int</code> pixel value in this
|
||||||
* <code>ColorModel</code> corresponding to the specified components.
|
* <code>ColorModel</code> corresponding to the specified components.
|
||||||
* @exception <code>ArrayIndexOutOfBoundsException</code> if
|
* @exception ArrayIndexOutOfBoundsException if
|
||||||
* the <code>components</code> array is not large enough to
|
* the <code>components</code> array is not large enough to
|
||||||
* hold all of the color and alpha components starting at
|
* hold all of the color and alpha components starting at
|
||||||
* <code>offset</code>
|
* <code>offset</code>
|
||||||
|
@ -1097,9 +1097,9 @@ public class DirectColorModel extends PackedColorModel {
|
||||||
* and alpha components
|
* and alpha components
|
||||||
* @return an <code>Object</code> representing an array of color and
|
* @return an <code>Object</code> representing an array of color and
|
||||||
* alpha components.
|
* alpha components.
|
||||||
* @exception <code>ClassCastException</code> if <code>obj</code>
|
* @exception ClassCastException if <code>obj</code>
|
||||||
* is not a primitive array of type <code>transferType</code>
|
* is not a primitive array of type <code>transferType</code>
|
||||||
* @exception <code>ArrayIndexOutOfBoundsException</code> if
|
* @exception ArrayIndexOutOfBoundsException if
|
||||||
* <code>obj</code> is not large enough to hold a pixel value
|
* <code>obj</code> is not large enough to hold a pixel value
|
||||||
* for this <code>ColorModel</code> or the <code>components</code>
|
* for this <code>ColorModel</code> or the <code>components</code>
|
||||||
* array is not large enough to hold all of the color and alpha
|
* array is not large enough to hold all of the color and alpha
|
||||||
|
|
|
@ -100,11 +100,11 @@ public interface ImageProducer {
|
||||||
* <code>ImageProducer</code> should respond by executing
|
* <code>ImageProducer</code> should respond by executing
|
||||||
* the following minimum set of <code>ImageConsumer</code>
|
* the following minimum set of <code>ImageConsumer</code>
|
||||||
* method calls:
|
* method calls:
|
||||||
* <pre>
|
* <pre>{@code
|
||||||
* ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >);
|
* ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >);
|
||||||
* ic.setPixels(...); // As many times as needed
|
* ic.setPixels(...); // As many times as needed
|
||||||
* ic.imageComplete();
|
* ic.imageComplete();
|
||||||
* </pre>
|
* }</pre>
|
||||||
* @param ic the specified <code>ImageConsumer</code>
|
* @param ic the specified <code>ImageConsumer</code>
|
||||||
* @see ImageConsumer#setHints
|
* @see ImageConsumer#setHints
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -98,6 +98,7 @@ import java.math.BigInteger;
|
||||||
* Index values greater than or equal to the map size, but less than
|
* Index values greater than or equal to the map size, but less than
|
||||||
* 2<sup><em>n</em></sup>, are undefined and return 0 for all color and
|
* 2<sup><em>n</em></sup>, are undefined and return 0 for all color and
|
||||||
* alpha components.
|
* alpha components.
|
||||||
|
* </a>
|
||||||
* <p>
|
* <p>
|
||||||
* For those methods that use a primitive array pixel representation of
|
* For those methods that use a primitive array pixel representation of
|
||||||
* type <code>transferType</code>, the array length is always one.
|
* type <code>transferType</code>, the array length is always one.
|
||||||
|
|
|
@ -37,7 +37,7 @@ import java.util.Enumeration;
|
||||||
* uses an array to produce pixel values for an Image. Here is an example
|
* uses an array to produce pixel values for an Image. Here is an example
|
||||||
* which calculates a 100x100 image representing a fade from black to blue
|
* which calculates a 100x100 image representing a fade from black to blue
|
||||||
* along the X axis and a fade from black to red along the Y axis:
|
* along the X axis and a fade from black to red along the Y axis:
|
||||||
* <pre>
|
* <pre>{@code
|
||||||
*
|
*
|
||||||
* int w = 100;
|
* int w = 100;
|
||||||
* int h = 100;
|
* int h = 100;
|
||||||
|
@ -52,12 +52,12 @@ import java.util.Enumeration;
|
||||||
* }
|
* }
|
||||||
* Image img = createImage(new MemoryImageSource(w, h, pix, 0, w));
|
* Image img = createImage(new MemoryImageSource(w, h, pix, 0, w));
|
||||||
*
|
*
|
||||||
* </pre>
|
* }</pre>
|
||||||
* The MemoryImageSource is also capable of managing a memory image which
|
* The MemoryImageSource is also capable of managing a memory image which
|
||||||
* varies over time to allow animation or custom rendering. Here is an
|
* varies over time to allow animation or custom rendering. Here is an
|
||||||
* example showing how to set up the animation source and signal changes
|
* example showing how to set up the animation source and signal changes
|
||||||
* in the data (adapted from the MemoryAnimationSourceDemo by Garth Dickie):
|
* in the data (adapted from the MemoryAnimationSourceDemo by Garth Dickie):
|
||||||
* <pre>
|
* <pre>{@code
|
||||||
*
|
*
|
||||||
* int pixels[];
|
* int pixels[];
|
||||||
* MemoryImageSource source;
|
* MemoryImageSource source;
|
||||||
|
@ -96,7 +96,7 @@ import java.util.Enumeration;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* </pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @see ImageProducer
|
* @see ImageProducer
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,14 +52,14 @@ package java.awt.image;
|
||||||
* <code>x, y</code> from <code>DataBuffer</code> <code>data</code>
|
* <code>x, y</code> from <code>DataBuffer</code> <code>data</code>
|
||||||
* and storing the pixel data in data elements of type
|
* and storing the pixel data in data elements of type
|
||||||
* <code>dataType</code>:
|
* <code>dataType</code>:
|
||||||
* <pre>
|
* <pre>{@code
|
||||||
* int dataElementSize = DataBuffer.getDataTypeSize(dataType);
|
* int dataElementSize = DataBuffer.getDataTypeSize(dataType);
|
||||||
* int bitnum = dataBitOffset + x*pixelBitStride;
|
* int bitnum = dataBitOffset + x*pixelBitStride;
|
||||||
* int element = data.getElem(y*scanlineStride + bitnum/dataElementSize);
|
* int element = data.getElem(y*scanlineStride + bitnum/dataElementSize);
|
||||||
* int shift = dataElementSize - (bitnum & (dataElementSize-1))
|
* int shift = dataElementSize - (bitnum & (dataElementSize-1))
|
||||||
* - pixelBitStride;
|
* - pixelBitStride;
|
||||||
* int pixel = (element >> shift) & ((1 << pixelBitStride) - 1);
|
* int pixel = (element >> shift) & ((1 << pixelBitStride) - 1);
|
||||||
* </pre>
|
* }</pre>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MultiPixelPackedSampleModel extends SampleModel
|
public class MultiPixelPackedSampleModel extends SampleModel
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.awt.Image;
|
||||||
* The PixelGrabber class implements an ImageConsumer which can be attached
|
* The PixelGrabber class implements an ImageConsumer which can be attached
|
||||||
* to an Image or ImageProducer object to retrieve a subset of the pixels
|
* to an Image or ImageProducer object to retrieve a subset of the pixels
|
||||||
* in that image. Here is an example:
|
* in that image. Here is an example:
|
||||||
* <pre>
|
* <pre>{@code
|
||||||
*
|
*
|
||||||
* public void handlesinglepixel(int x, int y, int pixel) {
|
* public void handlesinglepixel(int x, int y, int pixel) {
|
||||||
* int alpha = (pixel >> 24) & 0xff;
|
* int alpha = (pixel >> 24) & 0xff;
|
||||||
|
@ -65,7 +65,7 @@ import java.awt.Image;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* </pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @see ColorModel#getRGBdefault
|
* @see ColorModel#getRGBdefault
|
||||||
*
|
*
|
||||||
|
@ -165,8 +165,8 @@ public class PixelGrabber implements ImageConsumer {
|
||||||
* accumulated in the default RGB ColorModel. If the forceRGB
|
* accumulated in the default RGB ColorModel. If the forceRGB
|
||||||
* parameter is true, then the pixels will be accumulated in the
|
* parameter is true, then the pixels will be accumulated in the
|
||||||
* default RGB ColorModel anyway. A buffer is allocated by the
|
* default RGB ColorModel anyway. A buffer is allocated by the
|
||||||
* PixelGrabber to hold the pixels in either case. If (w < 0) or
|
* PixelGrabber to hold the pixels in either case. If {@code (w < 0)} or
|
||||||
* (h < 0), then they will default to the remaining width and
|
* {@code (h < 0)}, then they will default to the remaining width and
|
||||||
* height of the source data when that information is delivered.
|
* height of the source data when that information is delivered.
|
||||||
* @param img the image to retrieve the image data from
|
* @param img the image to retrieve the image data from
|
||||||
* @param x the x coordinate of the upper left corner of the rectangle
|
* @param x the x coordinate of the upper left corner of the rectangle
|
||||||
|
@ -233,10 +233,10 @@ public class PixelGrabber implements ImageConsumer {
|
||||||
* behaves in the following ways, depending on the value of
|
* behaves in the following ways, depending on the value of
|
||||||
* <code>ms</code>:
|
* <code>ms</code>:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li> If <code>ms</code> == 0, waits until all pixels are delivered
|
* <li> If {@code ms == 0}, waits until all pixels are delivered
|
||||||
* <li> If <code>ms</code> > 0, waits until all pixels are delivered
|
* <li> If {@code ms > 0}, waits until all pixels are delivered
|
||||||
* as timeout expires.
|
* as timeout expires.
|
||||||
* <li> If <code>ms</code> < 0, returns <code>true</code> if all pixels
|
* <li> If {@code ms < 0}, returns <code>true</code> if all pixels
|
||||||
* are grabbed, <code>false</code> otherwise and does not wait.
|
* are grabbed, <code>false</code> otherwise and does not wait.
|
||||||
* </ul>
|
* </ul>
|
||||||
* @param ms the number of milliseconds to wait for the image pixels
|
* @param ms the number of milliseconds to wait for the image pixels
|
||||||
|
|
|
@ -39,7 +39,7 @@ import java.awt.image.ColorModel;
|
||||||
* The only method which needs to be defined to create a useable image
|
* The only method which needs to be defined to create a useable image
|
||||||
* filter is the filterRGB method. Here is an example of a definition
|
* filter is the filterRGB method. Here is an example of a definition
|
||||||
* of a filter which swaps the red and blue components of an image:
|
* of a filter which swaps the red and blue components of an image:
|
||||||
* <pre>
|
* <pre>{@code
|
||||||
*
|
*
|
||||||
* class RedBlueSwapFilter extends RGBImageFilter {
|
* class RedBlueSwapFilter extends RGBImageFilter {
|
||||||
* public RedBlueSwapFilter() {
|
* public RedBlueSwapFilter() {
|
||||||
|
@ -56,7 +56,7 @@ import java.awt.image.ColorModel;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* </pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @see FilteredImageSource
|
* @see FilteredImageSource
|
||||||
* @see ImageFilter
|
* @see ImageFilter
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class ShortLookupTable extends LookupTable {
|
||||||
* @exception ArrayIndexOutOfBoundsException if <code>src</code> is
|
* @exception ArrayIndexOutOfBoundsException if <code>src</code> is
|
||||||
* longer than <code>dst</code> or if for any element
|
* longer than <code>dst</code> or if for any element
|
||||||
* <code>i</code> of <code>src</code>,
|
* <code>i</code> of <code>src</code>,
|
||||||
* <code>(src[i]&0xffff)-offset</code> is either less than
|
* {@code (src[i]&0xffff)-offset} is either less than
|
||||||
* zero or greater than or equal to the length of the
|
* zero or greater than or equal to the length of the
|
||||||
* lookup table for any band.
|
* lookup table for any band.
|
||||||
*/
|
*/
|
||||||
|
@ -165,7 +165,7 @@ public class ShortLookupTable extends LookupTable {
|
||||||
* @exception ArrayIndexOutOfBoundsException if <code>src</code> is
|
* @exception ArrayIndexOutOfBoundsException if <code>src</code> is
|
||||||
* longer than <code>dst</code> or if for any element
|
* longer than <code>dst</code> or if for any element
|
||||||
* <code>i</code> of <code>src</code>,
|
* <code>i</code> of <code>src</code>,
|
||||||
* <code>(src[i]&0xffff)-offset</code> is either less than
|
* {@code (src[i]&0xffff)-offset} is either less than
|
||||||
* zero or greater than or equal to the length of the
|
* zero or greater than or equal to the length of the
|
||||||
* lookup table for any band.
|
* lookup table for any band.
|
||||||
*/
|
*/
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue