undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
This commit is contained in:
commit
0a580b313d
70422 changed files with 17213626 additions and 0 deletions
58
test/jdk/java/beans/XMLEncoder/4741757/AbstractTest.java
Normal file
58
test/jdk/java/beans/XMLEncoder/4741757/AbstractTest.java
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2007, 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.
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.XMLDecoder;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
abstract class AbstractTest {
|
||||
public abstract int getValue();
|
||||
|
||||
public final String toString() {
|
||||
return Integer.toString(getValue());
|
||||
}
|
||||
|
||||
static void test(AbstractTest object) {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
|
||||
XMLEncoder encoder = new XMLEncoder(output);
|
||||
encoder.setPersistenceDelegate(
|
||||
object.getClass(),
|
||||
new DefaultPersistenceDelegate(new String[] {"value"}));
|
||||
|
||||
encoder.writeObject(object);
|
||||
encoder.close();
|
||||
|
||||
System.out.print(output);
|
||||
|
||||
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
|
||||
XMLDecoder decoder = new XMLDecoder(input);
|
||||
AbstractTest result = (AbstractTest) decoder.readObject();
|
||||
decoder.close();
|
||||
|
||||
if (object.getValue() != result.getValue())
|
||||
throw new Error("Should be " + object);
|
||||
}
|
||||
}
|
||||
50
test/jdk/java/beans/XMLEncoder/4741757/TestFieldAccess.java
Normal file
50
test/jdk/java/beans/XMLEncoder/4741757/TestFieldAccess.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2007, 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 4741757
|
||||
* @summary Tests encoding with wrong field name
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class TestFieldAccess extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
test(new TestFieldAccess(5));
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this field is the same as the name of property.
|
||||
*/
|
||||
private int value = -1;
|
||||
|
||||
private int property;
|
||||
|
||||
public TestFieldAccess(int value) {
|
||||
this.property = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.property;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2007, 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 4741757
|
||||
* @summary Tests stack overflow if equals is defined
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class TestStackOverflow extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
test(new TestStackOverflow(5));
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of this field is the same as the name of property.
|
||||
*/
|
||||
private int value = -1;
|
||||
|
||||
private int property;
|
||||
|
||||
public TestStackOverflow(int value) {
|
||||
this.property = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.property;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof TestStackOverflow) {
|
||||
TestStackOverflow test = (TestStackOverflow) object;
|
||||
return test.property == this.property;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
102
test/jdk/java/beans/XMLEncoder/6329581/Test6329581.java
Normal file
102
test/jdk/java/beans/XMLEncoder/6329581/Test6329581.java
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 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 6329581
|
||||
* @summary Tests encoding of a class with custom ClassLoader
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.ExceptionListener;
|
||||
import java.beans.XMLDecoder;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
public class Test6329581 extends URLClassLoader implements ExceptionListener {
|
||||
public static final class Bean {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new Test6329581().decode(new Test6329581().encode(Bean.class.getName()));
|
||||
}
|
||||
|
||||
private Test6329581() {
|
||||
super(new URL[] {
|
||||
Test6329581.class.getProtectionDomain().getCodeSource().getLocation()
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
Class c = findLoadedClass(name);
|
||||
if (c == null) {
|
||||
if (Bean.class.getName().equals(name)) {
|
||||
c = findClass(name);
|
||||
}
|
||||
else try {
|
||||
c = getParent().loadClass(name);
|
||||
}
|
||||
catch (ClassNotFoundException exception) {
|
||||
c = findClass(name);
|
||||
}
|
||||
}
|
||||
if (resolve) {
|
||||
resolveClass(c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public void exceptionThrown(Exception exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
|
||||
private void validate(Object object) {
|
||||
if (!object.getClass().getClassLoader().equals(this)) {
|
||||
throw new Error("Bean is loaded with unexpected class loader");
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] encode(String name) throws Exception {
|
||||
Object object = loadClass(name).newInstance();
|
||||
validate(object);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
XMLEncoder encoder = new XMLEncoder(out);
|
||||
encoder.setExceptionListener(this);
|
||||
encoder.writeObject(object);
|
||||
encoder.close();
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
private Object decode(byte[] array) {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(array);
|
||||
XMLDecoder decoder = new XMLDecoder(in, null, this, this);
|
||||
Object object = decoder.readObject();
|
||||
validate(object);
|
||||
decoder.close();
|
||||
return object;
|
||||
}
|
||||
}
|
||||
25
test/jdk/java/beans/XMLEncoder/6380849/Bean.java
Normal file
25
test/jdk/java/beans/XMLEncoder/6380849/Bean.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 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.
|
||||
*/
|
||||
|
||||
public class Bean {
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 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.
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
|
||||
public class BeanPersistenceDelegate
|
||||
extends DefaultPersistenceDelegate {
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 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 6380849
|
||||
* @summary Tests PersistenceDelegate finder
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
|
||||
public class TestPersistenceDelegate {
|
||||
|
||||
private static final XMLEncoder ENCODER = new XMLEncoder(System.out);
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Class<?> type = TestPersistenceDelegate.class;
|
||||
test(type, DefaultPersistenceDelegate.class);
|
||||
ENCODER.setPersistenceDelegate(type, new BeanPersistenceDelegate());
|
||||
test(type, BeanPersistenceDelegate.class);
|
||||
ENCODER.setPersistenceDelegate(type, null);
|
||||
test(type, DefaultPersistenceDelegate.class);
|
||||
// the following tests fails on previous build
|
||||
test(Bean.class, BeanPersistenceDelegate.class);
|
||||
test(BeanPersistenceDelegate.class, BeanPersistenceDelegate.class);
|
||||
}
|
||||
|
||||
private static void test(Class<?> type, Class<? extends PersistenceDelegate> expected) {
|
||||
PersistenceDelegate actual = ENCODER.getPersistenceDelegate(type);
|
||||
if ((actual == null) && (expected != null)) {
|
||||
throw new Error("expected delegate is not found");
|
||||
}
|
||||
if ((actual != null) && !actual.getClass().equals(expected)) {
|
||||
throw new Error("found unexpected delegate");
|
||||
}
|
||||
}
|
||||
}
|
||||
52
test/jdk/java/beans/XMLEncoder/6777487/TestBox.java
Normal file
52
test/jdk/java/beans/XMLEncoder/6777487/TestBox.java
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for BoxLayout
|
||||
* @run main TestBox
|
||||
*/
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
|
||||
public final class TestBox {
|
||||
private static final Integer OBJECT = Integer.valueOf(-123);
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestEncoder.test(
|
||||
new Box(BoxLayout.LINE_AXIS),
|
||||
new Box(BoxLayout.PAGE_AXIS) {
|
||||
@Override
|
||||
public FlowLayout getLayout() {
|
||||
return new FlowLayout() {
|
||||
private final Object axis = OBJECT;
|
||||
};
|
||||
}
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for CheckedCollection
|
||||
* @run main TestCheckedCollection
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class TestCheckedCollection {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = Collections.emptyList();
|
||||
TestEncoder.test(
|
||||
Collections.checkedCollection(list, String.class),
|
||||
new ArrayList() {
|
||||
private final Object type = OBJECT;
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/6777487/TestCheckedList.java
Normal file
48
test/jdk/java/beans/XMLEncoder/6777487/TestCheckedList.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for CheckedList
|
||||
* @run main TestCheckedList
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class TestCheckedList {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = Collections.emptyList();
|
||||
TestEncoder.test(
|
||||
Collections.checkedList(list, String.class),
|
||||
new ArrayList() {
|
||||
private final Object type = OBJECT;
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
49
test/jdk/java/beans/XMLEncoder/6777487/TestCheckedMap.java
Normal file
49
test/jdk/java/beans/XMLEncoder/6777487/TestCheckedMap.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for CheckedMap
|
||||
* @run main TestCheckedMap
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class TestCheckedMap {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<String, String> map = Collections.emptyMap();
|
||||
TestEncoder.test(
|
||||
Collections.checkedMap(map, String.class, String.class),
|
||||
new HashMap() {
|
||||
private final Object keyType = OBJECT;
|
||||
private final Object valueType = OBJECT;
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for CheckedRandomAccessList
|
||||
* @run main TestCheckedRandomAccessList
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class TestCheckedRandomAccessList {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
TestEncoder.test(
|
||||
Collections.checkedList(list, String.class),
|
||||
new ArrayList() {
|
||||
private final Object type = OBJECT;
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/6777487/TestCheckedSet.java
Normal file
48
test/jdk/java/beans/XMLEncoder/6777487/TestCheckedSet.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for CheckedSet
|
||||
* @run main TestCheckedSet
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class TestCheckedSet {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
Set<String> set = Collections.emptySet();
|
||||
TestEncoder.test(
|
||||
Collections.checkedSet(set, String.class),
|
||||
new HashSet() {
|
||||
private final Object type = OBJECT;
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for CheckedSortedMap
|
||||
* @run main TestCheckedSortedMap
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public final class TestCheckedSortedMap {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
SortedMap<String, String> map = new TreeMap<String, String>();
|
||||
TestEncoder.test(
|
||||
Collections.checkedSortedMap(map, String.class, String.class),
|
||||
new TreeMap() {
|
||||
private final Object keyType = OBJECT;
|
||||
private final Object valueType = OBJECT;
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for CheckedSortedSet
|
||||
* @run main TestCheckedSortedSet
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public final class TestCheckedSortedSet {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
SortedSet<String> set = new TreeSet<String>();
|
||||
TestEncoder.test(
|
||||
Collections.checkedSortedSet(set, String.class),
|
||||
new TreeSet() {
|
||||
private final Object type = OBJECT;
|
||||
},
|
||||
OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
58
test/jdk/java/beans/XMLEncoder/6777487/TestEncoder.java
Normal file
58
test/jdk/java/beans/XMLEncoder/6777487/TestEncoder.java
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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.
|
||||
*/
|
||||
|
||||
import java.beans.Expression;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
final class TestEncoder extends XMLEncoder {
|
||||
private Expression expression;
|
||||
|
||||
private TestEncoder() {
|
||||
super(System.out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExpression(Expression expression) {
|
||||
if (this.expression == null) {
|
||||
this.expression = expression;
|
||||
}
|
||||
super.writeExpression(expression);
|
||||
}
|
||||
|
||||
public static void test(Object provider, Object object, Object value) {
|
||||
TestEncoder encoder = new TestEncoder();
|
||||
encoder.setPersistenceDelegate(
|
||||
object.getClass(),
|
||||
encoder.getPersistenceDelegate(provider.getClass()));
|
||||
encoder.writeObject(object);
|
||||
encoder.close();
|
||||
|
||||
if (encoder.expression != null) {
|
||||
for (Object argument : encoder.expression.getArguments()) {
|
||||
if (value.equals(argument)) {
|
||||
throw new Error("Found private value!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
test/jdk/java/beans/XMLEncoder/6777487/TestEnumMap.java
Normal file
47
test/jdk/java/beans/XMLEncoder/6777487/TestEnumMap.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for EnumMap
|
||||
* @run main TestEnumMap
|
||||
*/
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class TestEnumMap {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestEncoder.test(
|
||||
new EnumMap<Point, String>(Point.class),
|
||||
new HashMap() {
|
||||
private final Object keyType = OBJECT;
|
||||
},
|
||||
OBJECT);
|
||||
}
|
||||
|
||||
public enum Point { X, Y, Z }
|
||||
}
|
||||
47
test/jdk/java/beans/XMLEncoder/6777487/TestEnumSet.java
Normal file
47
test/jdk/java/beans/XMLEncoder/6777487/TestEnumSet.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6777487
|
||||
* @summary Tests private field access for EnumSet
|
||||
* @run main TestEnumSet
|
||||
*/
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
|
||||
public final class TestEnumSet {
|
||||
private static final Object OBJECT = new Object();
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestEncoder.test(
|
||||
EnumSet.noneOf(Point.class),
|
||||
new HashSet() {
|
||||
private final Object elementType = OBJECT;
|
||||
},
|
||||
OBJECT);
|
||||
}
|
||||
|
||||
public enum Point { X, Y, Z }
|
||||
}
|
||||
162
test/jdk/java/beans/XMLEncoder/AbstractTest.java
Normal file
162
test/jdk/java/beans/XMLEncoder/AbstractTest.java
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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.
|
||||
*/
|
||||
|
||||
import java.beans.ExceptionListener;
|
||||
import java.beans.XMLDecoder;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
abstract class AbstractTest<T> implements ExceptionListener {
|
||||
final BeanValidator validator = new BeanValidator();
|
||||
|
||||
public final void exceptionThrown(Exception exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object to test.
|
||||
* This object will be encoded and decoded
|
||||
* and the object creation will be tested.
|
||||
*
|
||||
* @return an object to test
|
||||
*/
|
||||
protected abstract T getObject();
|
||||
|
||||
/**
|
||||
* Returns a different object to test.
|
||||
* If this object is not {@code null}
|
||||
* it will be encoded and decoded
|
||||
* and the object updating will be tested.
|
||||
*
|
||||
* @return a different object to test
|
||||
*/
|
||||
protected T getAnotherObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be overridden
|
||||
* if specified encoder should be initialized.
|
||||
*
|
||||
* @param encoder the XML encoder to initialize
|
||||
*/
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be overridden
|
||||
* if specified decoder should be initialized.
|
||||
*
|
||||
* @param decoder the XML decoder to initialize
|
||||
*/
|
||||
protected void initialize(XMLDecoder decoder) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be overridden
|
||||
* for test-specific comparison.
|
||||
*
|
||||
* @param before the object before encoding
|
||||
* @param after the object after decoding
|
||||
*/
|
||||
protected void validate(T before, T after) {
|
||||
this.validator.validate(before, after);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is entry point to start testing.
|
||||
*/
|
||||
final void test() {
|
||||
Bean.DEFAULT = null;
|
||||
T object = getObject();
|
||||
|
||||
System.out.println("Test object");
|
||||
validate(object, testObject(object));
|
||||
|
||||
System.out.println("Test object creating");
|
||||
validate(object, testBean(object));
|
||||
|
||||
Bean.DEFAULT = object;
|
||||
object = getAnotherObject();
|
||||
if (object != null) {
|
||||
System.out.println("Test another object");
|
||||
validate(object, testObject(object));
|
||||
|
||||
System.out.println("Test object updating");
|
||||
validate(object, testBean(object));
|
||||
}
|
||||
}
|
||||
|
||||
private T testBean(T object) {
|
||||
Bean bean = new Bean();
|
||||
bean.setValue(object);
|
||||
bean = testObject(bean);
|
||||
return (T) bean.getValue();
|
||||
}
|
||||
|
||||
private <Z> Z testObject(Z object) {
|
||||
byte[] array = writeObject(object);
|
||||
System.out.print(new String(array, Charset.forName("UTF-8")));
|
||||
return (Z) readObject(array);
|
||||
}
|
||||
|
||||
private byte[] writeObject(Object object) {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
XMLEncoder encoder = new XMLEncoder(output);
|
||||
encoder.setExceptionListener(this);
|
||||
initialize(encoder);
|
||||
encoder.writeObject(object);
|
||||
encoder.close();
|
||||
return output.toByteArray();
|
||||
}
|
||||
|
||||
private Object readObject(byte[] array) {
|
||||
ByteArrayInputStream input = new ByteArrayInputStream(array);
|
||||
XMLDecoder decoder = new XMLDecoder(input);
|
||||
decoder.setExceptionListener(this);
|
||||
initialize(decoder);
|
||||
Object object = decoder.readObject();
|
||||
decoder.close();
|
||||
return object;
|
||||
}
|
||||
|
||||
static Field getField(String name) {
|
||||
try {
|
||||
int index = name.lastIndexOf('.');
|
||||
String className = name.substring(0, index);
|
||||
String fieldName = name.substring(1 + index);
|
||||
Field field = Class.forName(className).getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new Error(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
test/jdk/java/beans/XMLEncoder/Bean.java
Normal file
36
test/jdk/java/beans/XMLEncoder/Bean.java
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 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.
|
||||
*/
|
||||
|
||||
public final class Bean {
|
||||
public static Object DEFAULT;
|
||||
|
||||
private Object value = DEFAULT;
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
284
test/jdk/java/beans/XMLEncoder/BeanValidator.java
Normal file
284
test/jdk/java/beans/XMLEncoder/BeanValidator.java
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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.
|
||||
*/
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
|
||||
final class BeanValidator {
|
||||
private final Map<Object, Object> cache = new IdentityHashMap<Object, Object>();
|
||||
|
||||
public void validate(Object object1, Object object2) {
|
||||
// compare references
|
||||
if (object1 == object2) {
|
||||
return;
|
||||
}
|
||||
// check for null
|
||||
if ((object1 == null) || (object2 == null)) {
|
||||
throw new IllegalStateException("could not compare object with null");
|
||||
}
|
||||
// resolve self references
|
||||
if (isCyclic(object1, object2)) {
|
||||
return;
|
||||
}
|
||||
// resolve cross references
|
||||
if (isCyclic(object2, object1)) {
|
||||
return;
|
||||
}
|
||||
Class type = object1.getClass();
|
||||
if (!type.equals(object2.getClass())) {
|
||||
// resolve different implementations of the Map.Entry interface
|
||||
if ((object1 instanceof Map.Entry) && (object2 instanceof Map.Entry)) {
|
||||
log("!!! special case", "Map.Entry");
|
||||
Map.Entry entry1 = (Map.Entry) object1;
|
||||
Map.Entry entry2 = (Map.Entry) object2;
|
||||
validate(entry1.getKey(), entry2.getKey());
|
||||
validate(entry1.getValue(), entry2.getValue());
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("could not compare objects with different types");
|
||||
}
|
||||
// validate elements of arrays
|
||||
if (type.isArray()) {
|
||||
int length = Array.getLength(object1);
|
||||
if (length != Array.getLength(object2)) {
|
||||
throw new IllegalStateException("could not compare arrays with different lengths");
|
||||
}
|
||||
try {
|
||||
this.cache.put(object1, object2);
|
||||
for (int i = 0; i < length; i++) {
|
||||
log("validate array element", Integer.valueOf(i));
|
||||
validate(Array.get(object1, i), Array.get(object2, i));
|
||||
}
|
||||
} finally {
|
||||
this.cache.remove(object1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// special case for collections: do not use equals
|
||||
boolean ignore = Collection.class.isAssignableFrom(type)
|
||||
|| Map.Entry.class.isAssignableFrom(type)
|
||||
|| Map.class.isAssignableFrom(type);
|
||||
// validate objects using equals()
|
||||
// we assume that the method equals(Object) can be called,
|
||||
// if the class declares such method
|
||||
if (!ignore && isDefined(type, "equals", Object.class)) {
|
||||
if (object1.equals(object2)) {
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("the first object is not equal to the second one");
|
||||
}
|
||||
// validate comparable objects using compareTo()
|
||||
// we assume that the method compareTo(Object) can be called,
|
||||
// if the class declares such method and implements interface Comparable
|
||||
if (Comparable.class.isAssignableFrom(type) && isDefined(type, "compareTo", Object.class)) {
|
||||
Comparable cmp = (Comparable) object1;
|
||||
if (0 == cmp.compareTo(object2)) {
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("the first comparable object is not equal to the second one");
|
||||
}
|
||||
try {
|
||||
this.cache.put(object1, object2);
|
||||
// validate values of public fields
|
||||
for (Field field : type.getFields()) {
|
||||
int mod = field.getModifiers();
|
||||
if (!Modifier.isStatic(mod)) {
|
||||
log("validate field", field.getName());
|
||||
validate(object1, object2, field);
|
||||
}
|
||||
}
|
||||
// validate values of properties
|
||||
for (PropertyDescriptor pd : getDescriptors(type)) {
|
||||
Method method = pd.getReadMethod();
|
||||
if (method != null) {
|
||||
log("validate property", pd.getName());
|
||||
validate(object1, object2, method);
|
||||
}
|
||||
}
|
||||
// validate contents of maps
|
||||
if (SortedMap.class.isAssignableFrom(type)) {
|
||||
validate((Map) object1, (Map) object2, true);
|
||||
} else if (Map.class.isAssignableFrom(type)) {
|
||||
validate((Map) object1, (Map) object2, false);
|
||||
}
|
||||
// validate contents of collections
|
||||
if (SortedSet.class.isAssignableFrom(type)) {
|
||||
validate((Collection) object1, (Collection) object2, true);
|
||||
} else if (List.class.isAssignableFrom(type)) {
|
||||
validate((Collection) object1, (Collection) object2, true);
|
||||
} else if (Queue.class.isAssignableFrom(type)) {
|
||||
validate((Collection) object1, (Collection) object2, true);
|
||||
} else if (Collection.class.isAssignableFrom(type)) {
|
||||
validate((Collection) object1, (Collection) object2, false);
|
||||
}
|
||||
} finally {
|
||||
this.cache.remove(object1);
|
||||
}
|
||||
}
|
||||
|
||||
private void validate(Object object1, Object object2, Field field) {
|
||||
try {
|
||||
object1 = field.get(object1);
|
||||
object2 = field.get(object2);
|
||||
|
||||
validate(object1, object2);
|
||||
}
|
||||
catch (IllegalAccessException exception) {
|
||||
log(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void validate(Object object1, Object object2, Method method) {
|
||||
try {
|
||||
object1 = method.invoke(object1);
|
||||
object2 = method.invoke(object2);
|
||||
|
||||
validate(object1, object2);
|
||||
}
|
||||
catch (IllegalAccessException exception) {
|
||||
log(exception);
|
||||
}
|
||||
catch (InvocationTargetException exception) {
|
||||
log(exception.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
private void validate(Collection c1, Collection c2, boolean sorted) {
|
||||
if (c1.size() != c2.size()) {
|
||||
throw new IllegalStateException("could not compare collections with different sizes");
|
||||
}
|
||||
if (sorted) {
|
||||
Iterator first = c1.iterator();
|
||||
Iterator second = c2.iterator();
|
||||
for (int i = 0; first.hasNext() && second.hasNext(); i++) {
|
||||
log("validate collection element", Integer.valueOf(i));
|
||||
validate(first.next(), second.next());
|
||||
}
|
||||
if (first.hasNext() || second.hasNext()) {
|
||||
throw new IllegalStateException("one collection contains more elements than another one");
|
||||
}
|
||||
} else {
|
||||
List list = new ArrayList(c2);
|
||||
Iterator first = c1.iterator();
|
||||
for (int i = 0; first.hasNext(); i++) {
|
||||
Object value = first.next();
|
||||
log("validate collection element", Integer.valueOf(i));
|
||||
Iterator second = list.iterator();
|
||||
for (int j = 0; second.hasNext(); j++) {
|
||||
log("validate collection element against", Integer.valueOf(j));
|
||||
try {
|
||||
validate(value, second.next());
|
||||
second.remove();
|
||||
break;
|
||||
} catch (IllegalStateException exception) {
|
||||
if (!second.hasNext()) {
|
||||
throw new IllegalStateException("one collection does not contain some elements from another one", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validate(Map map1, Map map2, boolean sorted) {
|
||||
validate(map1.entrySet(), map2.entrySet(), sorted);
|
||||
}
|
||||
|
||||
private boolean isCyclic(Object object1, Object object2) {
|
||||
Object object = this.cache.get(object1);
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
if (object == object2) {
|
||||
return true;
|
||||
}
|
||||
throw new IllegalStateException("could not resolve cyclic reference");
|
||||
}
|
||||
|
||||
private boolean isDefined(Class type, String name, Class... params) {
|
||||
try {
|
||||
return type.equals(type.getMethod(name, params).getDeclaringClass());
|
||||
}
|
||||
catch (NoSuchMethodException exception) {
|
||||
log(exception);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final PropertyDescriptor[] DESCRIPTORS = {};
|
||||
|
||||
private PropertyDescriptor[] getDescriptors(Class type) {
|
||||
try {
|
||||
return Introspector.getBeanInfo(type, Object.class).getPropertyDescriptors();
|
||||
}
|
||||
catch (IntrospectionException exception) {
|
||||
log(exception);
|
||||
}
|
||||
return DESCRIPTORS;
|
||||
}
|
||||
|
||||
private final StringBuilder sb = new StringBuilder(1024);
|
||||
|
||||
private void log(String message, Object value) {
|
||||
this.sb.setLength(0);
|
||||
int size = this.cache.size();
|
||||
while (0 < size--) {
|
||||
this.sb.append(" ");
|
||||
}
|
||||
this.sb.append(" - ");
|
||||
this.sb.append(message);
|
||||
if (value != null) {
|
||||
this.sb.append(": ");
|
||||
this.sb.append(value);
|
||||
}
|
||||
System.out.println(this.sb.toString());
|
||||
}
|
||||
|
||||
private void log(Throwable throwable) {
|
||||
this.sb.setLength(0);
|
||||
int size = this.cache.size();
|
||||
while (0 < size--) {
|
||||
this.sb.append(" ");
|
||||
}
|
||||
this.sb.append(" ? ");
|
||||
this.sb.append(throwable);
|
||||
System.out.println(this.sb.toString());
|
||||
}
|
||||
}
|
||||
165
test/jdk/java/beans/XMLEncoder/ReferenceToNonStaticField.java
Normal file
165
test/jdk/java/beans/XMLEncoder/ReferenceToNonStaticField.java
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2024, 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.
|
||||
*/
|
||||
|
||||
import java.awt.font.TextAttribute;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8060027
|
||||
* @run main/othervm ReferenceToNonStaticField
|
||||
*/
|
||||
public final class ReferenceToNonStaticField
|
||||
extends AbstractTest<ReferenceToNonStaticField.TestValue> {
|
||||
|
||||
public static final class TestValue {
|
||||
|
||||
// reference to static field
|
||||
public TextAttribute font_default = TextAttribute.FONT;
|
||||
public TextAttribute family_default = TextAttribute.FAMILY;
|
||||
public TextAttribute family_set1; // will be set to the same as default
|
||||
public TextAttribute family_set2; // will be set to the same as default
|
||||
public TextAttribute family_set3; // will be set to the same as default
|
||||
|
||||
// primitive small
|
||||
public int int_1_default = 1;
|
||||
public int int_10_default = 10;
|
||||
public int int_10_set1; // will be set to the same as default
|
||||
public int int_10_set2; // will be set to the same as default
|
||||
public int int_10_set3; // will be set to the same as default
|
||||
|
||||
// primitive big
|
||||
public int int_1000_default = 1000;
|
||||
public int int_2000_default = 2000;
|
||||
public int int_2000_set1; // will be set to the same as default
|
||||
public int int_2000_set2; // will be set to the same as default
|
||||
public int int_2000_set3; // will be set to the same as default
|
||||
|
||||
// wrappers
|
||||
public Integer integer_1_default = new Integer(1);
|
||||
public Integer integer_10_default = new Integer(10);
|
||||
public Integer integer_10_set1; // will be set to the same as default
|
||||
public Integer integer_10_set2; // will be set to the same as default
|
||||
public Integer integer_10_set3; // will be set to the same as default
|
||||
|
||||
public TestValue() {
|
||||
}
|
||||
|
||||
public TestValue(final Object ignored) {
|
||||
// set some fields to non-default values, so they will be saved
|
||||
family_set1 = family_default;
|
||||
family_set3 = family_default;
|
||||
family_set2 = family_default;
|
||||
int_10_set1 = int_10_default;
|
||||
int_10_set2 = int_10_default;
|
||||
int_10_set3 = int_10_default;
|
||||
int_2000_set1 = int_2000_default;
|
||||
int_2000_set2 = int_2000_default;
|
||||
int_2000_set3 = int_2000_default;
|
||||
integer_10_set1 = integer_10_default;
|
||||
integer_10_set2 = integer_10_default;
|
||||
integer_10_set3 = integer_10_default;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
new ReferenceToNonStaticField().test();
|
||||
}
|
||||
|
||||
protected TestValue getObject() {
|
||||
return new TestValue(new Object());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate(final TestValue before,final TestValue after) {
|
||||
super.validate(before, after);
|
||||
validate(before);
|
||||
validate(after);
|
||||
}
|
||||
|
||||
private static void validate(final TestValue object) {
|
||||
// reference to static field
|
||||
if (object.font_default != TextAttribute.FONT) {
|
||||
throw new Error("Wrong font_default: " + object.font_default);
|
||||
}
|
||||
if (object.family_default != TextAttribute.FAMILY) {
|
||||
throw new Error("Wrong family_default: " + object.family_default);
|
||||
}
|
||||
if (object.family_set1 != object.family_default) {
|
||||
throw new Error("Wrong family_set1: " + object.family_set1);
|
||||
}
|
||||
if (object.family_set2 != object.family_default) {
|
||||
throw new Error("Wrong family_set2: " + object.family_set2);
|
||||
}
|
||||
if (object.family_set3 != object.family_default) {
|
||||
throw new Error("Wrong family_set3: " + object.family_set3);
|
||||
}
|
||||
// primitive small
|
||||
if (object.int_1_default != 1) {
|
||||
throw new Error("Wrong int_1_default: " + object.int_1_default);
|
||||
}
|
||||
if (object.int_10_default != 10) {
|
||||
throw new Error("Wrong int_10_default: " + object.int_10_default);
|
||||
}
|
||||
if (object.int_10_set1 != object.int_10_default) {
|
||||
throw new Error("Wrong int_10_set1: " + object.int_10_set1);
|
||||
}
|
||||
if (object.int_10_set2 != object.int_10_default) {
|
||||
throw new Error("Wrong int_10_set2: " + object.int_10_set2);
|
||||
}
|
||||
if (object.int_10_set3 != object.int_10_default) {
|
||||
throw new Error("Wrong int_10_set3: " + object.int_10_set3);
|
||||
}
|
||||
// primitive big
|
||||
if (object.int_1000_default != 1000) {
|
||||
throw new Error("Wrong int_1000_default: " + object.int_1000_default);
|
||||
}
|
||||
if (object.int_2000_default != 2000) {
|
||||
throw new Error("Wrong int_2000_default: " + object.int_2000_default);
|
||||
}
|
||||
if (object.int_2000_set1 != object.int_2000_default) {
|
||||
throw new Error("Wrong int_2000_set1: " + object.int_2000_set1);
|
||||
}
|
||||
if (object.int_2000_set2 != object.int_2000_default) {
|
||||
throw new Error("Wrong int_2000_set2: " + object.int_2000_set2);
|
||||
}
|
||||
if (object.int_2000_set3 != object.int_2000_default) {
|
||||
throw new Error("Wrong int_2000_set3: " + object.int_2000_set3);
|
||||
}
|
||||
// wrappers
|
||||
if (!object.integer_1_default.equals(new Integer(1))) {
|
||||
throw new Error("Wrong integer_1_default: " + object.integer_1_default);
|
||||
}
|
||||
if (!object.integer_10_default.equals(new Integer(10))) {
|
||||
throw new Error("Wrong integer_10_default: " + object.integer_10_default);
|
||||
}
|
||||
if (object.integer_10_set1 != object.integer_10_default) {
|
||||
throw new Error("Wrong integer_10_set1: " + object.integer_10_set1);
|
||||
}
|
||||
if (object.integer_10_set2 != object.integer_10_default) {
|
||||
throw new Error("Wrong integer_10_set2: " + object.integer_10_set2);
|
||||
}
|
||||
if (object.integer_10_set3 != object.integer_10_default) {
|
||||
throw new Error("Wrong integer_10_set3: " + object.integer_10_set3);
|
||||
}
|
||||
}
|
||||
}
|
||||
409
test/jdk/java/beans/XMLEncoder/Test4625418.java
Normal file
409
test/jdk/java/beans/XMLEncoder/Test4625418.java
Normal file
|
|
@ -0,0 +1,409 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2022, 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 4625418 8239965 8290488
|
||||
* @summary Tests XML <a href="http://download.java.net/jdk6/docs/technotes/guides/intl/encoding.doc.html">encoding</a>
|
||||
* @author Sergey Malenkov
|
||||
* @run main/timeout=360 Test4625418
|
||||
*/
|
||||
|
||||
import java.beans.ExceptionListener;
|
||||
import java.beans.XMLDecoder;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
|
||||
public final class Test4625418 implements ExceptionListener {
|
||||
|
||||
private static final String[] encodings = {
|
||||
"ASCII",
|
||||
"Big5",
|
||||
//"Big5-HKSCS",
|
||||
//"Big5_HKSCS",
|
||||
"Big5_Solaris",
|
||||
//"Cp037",
|
||||
"Cp1006",
|
||||
//"Cp1025",
|
||||
//"Cp1026",
|
||||
"Cp1046",
|
||||
"Cp1047",
|
||||
"Cp1097",
|
||||
"Cp1098",
|
||||
//"Cp1112",
|
||||
//"Cp1122",
|
||||
//"Cp1123",
|
||||
"Cp1124",
|
||||
//"Cp1140",
|
||||
//"Cp1141",
|
||||
//"Cp1142",
|
||||
//"Cp1143",
|
||||
//"Cp1144",
|
||||
//"Cp1145",
|
||||
//"Cp1146",
|
||||
//"Cp1147",
|
||||
//"Cp1148",
|
||||
//"Cp1149",
|
||||
"Cp1250",
|
||||
"Cp1251",
|
||||
"Cp1252",
|
||||
"Cp1253",
|
||||
"Cp1254",
|
||||
"Cp1255",
|
||||
"Cp1256",
|
||||
"Cp1257",
|
||||
"Cp1258",
|
||||
//"Cp1381",
|
||||
//"Cp1383",
|
||||
//"Cp273",
|
||||
//"Cp277",
|
||||
//"Cp278",
|
||||
//"Cp280",
|
||||
//"Cp284",
|
||||
//"Cp285",
|
||||
//"Cp297",
|
||||
//"Cp33722",
|
||||
//"Cp420",
|
||||
//"Cp424",
|
||||
"Cp437",
|
||||
//"Cp500",
|
||||
//"Cp50220",
|
||||
//"Cp50221",
|
||||
"Cp737",
|
||||
"Cp775",
|
||||
//"Cp834",
|
||||
//"Cp838",
|
||||
"Cp850",
|
||||
"Cp852",
|
||||
"Cp855",
|
||||
"Cp856",
|
||||
"Cp857",
|
||||
"Cp858",
|
||||
"Cp860",
|
||||
"Cp861",
|
||||
"Cp862",
|
||||
"Cp863",
|
||||
//"Cp864",
|
||||
"Cp865",
|
||||
"Cp866",
|
||||
"Cp868",
|
||||
"Cp869",
|
||||
//"Cp870",
|
||||
//"Cp871",
|
||||
"Cp874",
|
||||
//"Cp875",
|
||||
//"Cp918",
|
||||
"Cp921",
|
||||
"Cp922",
|
||||
//"Cp930",
|
||||
"Cp933",
|
||||
//"Cp935",
|
||||
//"Cp937",
|
||||
//"Cp939",
|
||||
//"Cp942",
|
||||
//"Cp942C",
|
||||
//"Cp943",
|
||||
//"Cp943C",
|
||||
"Cp948",
|
||||
"Cp949",
|
||||
//"Cp949C",
|
||||
"Cp950",
|
||||
"Cp964",
|
||||
//"Cp970",
|
||||
//"EUC-JP",
|
||||
"EUC-KR",
|
||||
"EUC_CN",
|
||||
//"EUC_JP",
|
||||
//"EUC_JP_LINUX",
|
||||
//"EUC_JP_Solaris",
|
||||
"EUC_KR",
|
||||
//"EUC_TW",
|
||||
"GB18030",
|
||||
"GB2312",
|
||||
"GBK",
|
||||
//"IBM-Thai",
|
||||
"IBM00858",
|
||||
//"IBM01140",
|
||||
//"IBM01141",
|
||||
//"IBM01142",
|
||||
//"IBM01143",
|
||||
//"IBM01144",
|
||||
//"IBM01145",
|
||||
//"IBM01146",
|
||||
//"IBM01147",
|
||||
//"IBM01148",
|
||||
//"IBM01149",
|
||||
//"IBM037",
|
||||
//"IBM1026",
|
||||
"IBM1047",
|
||||
//"IBM273",
|
||||
//"IBM277",
|
||||
//"IBM278",
|
||||
//"IBM280",
|
||||
//"IBM284",
|
||||
//"IBM285",
|
||||
//"IBM297",
|
||||
//"IBM420",
|
||||
//"IBM424",
|
||||
"IBM437",
|
||||
//"IBM500",
|
||||
"IBM775",
|
||||
"IBM850",
|
||||
"IBM852",
|
||||
"IBM855",
|
||||
"IBM857",
|
||||
"IBM860",
|
||||
"IBM861",
|
||||
"IBM862",
|
||||
"IBM863",
|
||||
//"IBM864",
|
||||
"IBM865",
|
||||
"IBM866",
|
||||
"IBM868",
|
||||
"IBM869",
|
||||
//"IBM870",
|
||||
//"IBM871",
|
||||
//"IBM918",
|
||||
//"ISCII91",
|
||||
//"ISO-2022-CN",
|
||||
"ISO-2022-JP",
|
||||
"ISO-2022-KR",
|
||||
"ISO-8859-1",
|
||||
"ISO-8859-13",
|
||||
"ISO-8859-15",
|
||||
"ISO-8859-2",
|
||||
"ISO-8859-3",
|
||||
"ISO-8859-4",
|
||||
"ISO-8859-5",
|
||||
"ISO-8859-6",
|
||||
"ISO-8859-7",
|
||||
"ISO-8859-8",
|
||||
"ISO-8859-9",
|
||||
//"ISO2022CN",
|
||||
"ISO2022JP",
|
||||
"ISO2022KR",
|
||||
//"ISO2022_CN_CNS",
|
||||
//"ISO2022_CN_GB",
|
||||
"ISO8859_1",
|
||||
"ISO8859_13",
|
||||
"ISO8859_15",
|
||||
"ISO8859_2",
|
||||
"ISO8859_3",
|
||||
"ISO8859_4",
|
||||
"ISO8859_5",
|
||||
"ISO8859_6",
|
||||
"ISO8859_7",
|
||||
"ISO8859_8",
|
||||
"ISO8859_9",
|
||||
//"JISAutoDetect",
|
||||
//"JIS_X0201",
|
||||
//"JIS_X0212-1990",
|
||||
"KOI8-R",
|
||||
"KOI8-U",
|
||||
"KOI8_R",
|
||||
"KOI8_U",
|
||||
"MS874",
|
||||
//"MS932",
|
||||
//"MS936",
|
||||
"MS949",
|
||||
"MS950",
|
||||
//"MS950_HKSCS",
|
||||
"MacArabic",
|
||||
"MacCentralEurope",
|
||||
"MacCroatian",
|
||||
"MacCyrillic",
|
||||
//"MacDingbat",
|
||||
"MacGreek",
|
||||
"MacHebrew",
|
||||
"MacIceland",
|
||||
"MacRoman",
|
||||
"MacRomania",
|
||||
//"MacSymbol",
|
||||
"MacThai",
|
||||
"MacTurkish",
|
||||
"MacUkraine",
|
||||
//"PCK",
|
||||
//"SJIS",
|
||||
//"Shift_JIS",
|
||||
"TIS-620",
|
||||
"TIS620",
|
||||
"US-ASCII",
|
||||
"UTF-16",
|
||||
"UTF-16BE",
|
||||
"UTF-16LE",
|
||||
"UTF-32",
|
||||
"UTF-32BE",
|
||||
"UTF-32LE",
|
||||
"UTF-8",
|
||||
"UTF8",
|
||||
"UTF_32",
|
||||
"UTF_32BE",
|
||||
//"UTF_32BE_BOM",
|
||||
"UTF_32LE",
|
||||
//"UTF_32LE_BOM",
|
||||
"UnicodeBig",
|
||||
"UnicodeBigUnmarked",
|
||||
"UnicodeLittle",
|
||||
"UnicodeLittleUnmarked",
|
||||
"windows-1250",
|
||||
"windows-1251",
|
||||
"windows-1252",
|
||||
"windows-1253",
|
||||
"windows-1254",
|
||||
"windows-1255",
|
||||
"windows-1256",
|
||||
"windows-1257",
|
||||
"windows-1258",
|
||||
//"windows-31j",
|
||||
//"x-Big5_Solaris",
|
||||
//"x-EUC-TW",
|
||||
"x-IBM1006",
|
||||
//"x-IBM1025",
|
||||
"x-IBM1046",
|
||||
"x-IBM1097",
|
||||
"x-IBM1098",
|
||||
//"x-IBM1112",
|
||||
//"x-IBM1122",
|
||||
//"x-IBM1123",
|
||||
"x-IBM1124",
|
||||
//"x-IBM1381",
|
||||
//"x-IBM1383",
|
||||
//"x-IBM33722",
|
||||
"x-IBM737",
|
||||
//"x-IBM834",
|
||||
"x-IBM856",
|
||||
"x-IBM874",
|
||||
//"x-IBM875",
|
||||
"x-IBM921",
|
||||
"x-IBM922",
|
||||
//"x-IBM930",
|
||||
"x-IBM933",
|
||||
//"x-IBM935",
|
||||
//"x-IBM937",
|
||||
//"x-IBM939",
|
||||
//"x-IBM942",
|
||||
//"x-IBM942C",
|
||||
//"x-IBM943",
|
||||
//"x-IBM943C",
|
||||
"x-IBM948",
|
||||
"x-IBM949",
|
||||
//"x-IBM949C",
|
||||
"x-IBM950",
|
||||
"x-IBM964",
|
||||
//"x-IBM970",
|
||||
//"x-ISCII91",
|
||||
//"x-ISO2022-CN-CNS",
|
||||
//"x-ISO2022-CN-GB",
|
||||
//"x-JIS0208",
|
||||
//"x-JISAutoDetect",
|
||||
"x-Johab",
|
||||
//"x-MS950-HKSCS",
|
||||
"x-MacArabic",
|
||||
"x-MacCentralEurope",
|
||||
"x-MacCroatian",
|
||||
"x-MacCyrillic",
|
||||
//"x-MacDingbat",
|
||||
"x-MacGreek",
|
||||
"x-MacHebrew",
|
||||
"x-MacIceland",
|
||||
"x-MacRoman",
|
||||
"x-MacRomania",
|
||||
//"x-MacSymbol",
|
||||
"x-MacThai",
|
||||
"x-MacTurkish",
|
||||
"x-MacUkraine",
|
||||
//"x-PCK",
|
||||
"x-UTF-16LE-BOM",
|
||||
//"x-UTF-32BE-BOM",
|
||||
//"x-UTF-32LE-BOM",
|
||||
//"x-euc-jp-linux",
|
||||
//"x-eucJP-Open",
|
||||
"x-iso-8859-11",
|
||||
"x-mswin-936",
|
||||
//"x-windows-50220",
|
||||
//"x-windows-50221",
|
||||
"x-windows-874",
|
||||
"x-windows-949",
|
||||
"x-windows-950",
|
||||
//"x-windows-iso2022jp",
|
||||
};
|
||||
|
||||
public static void main(final String[] args) {
|
||||
final String string = createString(0x10000);
|
||||
for (String encoding : encodings) {
|
||||
System.out.println("Test encoding: " + encoding);
|
||||
new Test4625418(encoding).test(string);
|
||||
}
|
||||
}
|
||||
|
||||
private static String createString(int length) {
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
while (0 < length--)
|
||||
sb.append((char) length);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private final String encoding;
|
||||
|
||||
private Test4625418(final String encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
private void test(String string) {
|
||||
try {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0);
|
||||
encoder.setExceptionListener(this);
|
||||
encoder.writeObject(string);
|
||||
encoder.close();
|
||||
|
||||
InputStream input = new ByteArrayInputStream(output.toByteArray());
|
||||
XMLDecoder decoder = new XMLDecoder(input);
|
||||
decoder.setExceptionListener(this);
|
||||
Object object = decoder.readObject();
|
||||
decoder.close();
|
||||
|
||||
if (!string.equals(object)) {
|
||||
throw new Error(this.encoding + " - can't read properly");
|
||||
}
|
||||
}
|
||||
catch (IllegalCharsetNameException exception) {
|
||||
throw new Error(this.encoding + " - illegal charset name", exception);
|
||||
}
|
||||
catch (UnsupportedCharsetException exception) {
|
||||
throw new Error(this.encoding + " - unsupported charset", exception);
|
||||
}
|
||||
catch (UnsupportedOperationException exception) {
|
||||
throw new Error(this.encoding + " - unsupported encoder", exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void exceptionThrown(Exception exception) {
|
||||
throw new Error(this.encoding + " - internal", exception);
|
||||
}
|
||||
}
|
||||
111
test/jdk/java/beans/XMLEncoder/Test4631471.java
Normal file
111
test/jdk/java/beans/XMLEncoder/Test4631471.java
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2024, 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 4631471 6972468
|
||||
* @summary Tests DefaultTreeModel encoding
|
||||
* @run main/othervm Test4631471
|
||||
* @author Sergey Malenkov, Mark Davidson
|
||||
*/
|
||||
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
public abstract class Test4631471 extends AbstractTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
main();
|
||||
}
|
||||
|
||||
private static void main() throws Exception {
|
||||
// the DefaultMutableTreeNode will archive correctly
|
||||
new Test4631471() {
|
||||
protected Object getObject() {
|
||||
return getRoot();
|
||||
}
|
||||
}.test();
|
||||
|
||||
// the DefaultTreeModel will also archive correctly
|
||||
new Test4631471() {
|
||||
protected Object getObject() {
|
||||
return getModel();
|
||||
}
|
||||
}.test();
|
||||
|
||||
// create a new model from the root node
|
||||
// this simulates the MetaData ctor:
|
||||
// registerConstructor("javax.swing.tree.DefaultTreeModel", new String[]{"root"});
|
||||
new Test4631471() {
|
||||
protected Object getObject() {
|
||||
return new DefaultTreeModel((TreeNode) getModel().getRoot());
|
||||
}
|
||||
}.test();
|
||||
|
||||
// the JTree will archive correctly too
|
||||
new Test4631471() {
|
||||
protected Object getObject() {
|
||||
return getTree();
|
||||
}
|
||||
}.test();
|
||||
}
|
||||
|
||||
protected final void validate(Object before, Object after) {
|
||||
// do not any validation
|
||||
}
|
||||
|
||||
public static TreeNode getRoot() {
|
||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode("root");
|
||||
DefaultMutableTreeNode first = new DefaultMutableTreeNode("first");
|
||||
DefaultMutableTreeNode second = new DefaultMutableTreeNode("second");
|
||||
DefaultMutableTreeNode third = new DefaultMutableTreeNode("third");
|
||||
|
||||
first.add(new DefaultMutableTreeNode("1.1"));
|
||||
first.add(new DefaultMutableTreeNode("1.2"));
|
||||
first.add(new DefaultMutableTreeNode("1.3"));
|
||||
|
||||
second.add(new DefaultMutableTreeNode("2.1"));
|
||||
second.add(new DefaultMutableTreeNode("2.2"));
|
||||
second.add(new DefaultMutableTreeNode("2.3"));
|
||||
|
||||
third.add(new DefaultMutableTreeNode("3.1"));
|
||||
third.add(new DefaultMutableTreeNode("3.2"));
|
||||
third.add(new DefaultMutableTreeNode("3.3"));
|
||||
|
||||
node.add(first);
|
||||
node.add(second);
|
||||
node.add(third);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public static JTree getTree() {
|
||||
return new JTree(getRoot());
|
||||
}
|
||||
|
||||
public static TreeModel getModel() {
|
||||
return getTree().getModel();
|
||||
}
|
||||
}
|
||||
59
test/jdk/java/beans/XMLEncoder/Test4646747.java
Normal file
59
test/jdk/java/beans/XMLEncoder/Test4646747.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2024, 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 4646747
|
||||
* @summary Tests that persistence delegate is correct after memory stress
|
||||
* @run main/othervm -Xms16m -Xmx16m Test4646747
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
/**
|
||||
* This bug was introduced in 1.4 FCS but was working in 1.4.beta3
|
||||
*/
|
||||
public class Test4646747 {
|
||||
public static void main(String[] args) {
|
||||
XMLEncoder encoder = new XMLEncoder(System.out);
|
||||
encoder.setPersistenceDelegate(Test4646747.class, new MyPersistenceDelegate());
|
||||
// WARNING: This can eat up a lot of memory
|
||||
Object[] obs = new Object[10000];
|
||||
while (obs != null) {
|
||||
try {
|
||||
obs = new Object[obs.length + obs.length / 3];
|
||||
}
|
||||
catch (OutOfMemoryError error) {
|
||||
obs = null;
|
||||
}
|
||||
}
|
||||
PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class);
|
||||
if (!(pd instanceof MyPersistenceDelegate))
|
||||
throw new Error("persistence delegate has been lost");
|
||||
}
|
||||
|
||||
private static class MyPersistenceDelegate extends DefaultPersistenceDelegate {
|
||||
}
|
||||
}
|
||||
63
test/jdk/java/beans/XMLEncoder/Test4652928.java
Normal file
63
test/jdk/java/beans/XMLEncoder/Test4652928.java
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2024, 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 4652928
|
||||
* @summary Tests encoding of collections
|
||||
* @run main/othervm Test4652928
|
||||
* @author Sergey Malenkov, Mark Davidson
|
||||
*/
|
||||
|
||||
import java.beans.beancontext.BeanContext;
|
||||
import java.beans.beancontext.BeanContextServicesSupport;
|
||||
import java.beans.beancontext.BeanContextSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class Test4652928 extends AbstractTest<List> {
|
||||
public static void main(String[] args) {
|
||||
new Test4652928().test();
|
||||
}
|
||||
|
||||
protected List getObject() {
|
||||
List<BeanContext> list = new ArrayList<BeanContext>();
|
||||
list.add(fill(new BeanContextSupport()));
|
||||
list.add(fill(new BeanContextServicesSupport()));
|
||||
return list;
|
||||
}
|
||||
|
||||
private static BeanContext fill(BeanContext context) {
|
||||
context.add(new JLabel("label"));
|
||||
context.add(new JButton("button"));
|
||||
|
||||
JButton button = new JButton();
|
||||
button.setText("another button");
|
||||
context.add(button);
|
||||
|
||||
return context;
|
||||
}
|
||||
}
|
||||
145
test/jdk/java/beans/XMLEncoder/Test4679556.java
Normal file
145
test/jdk/java/beans/XMLEncoder/Test4679556.java
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2024, 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 4679556
|
||||
* @summary Tests for duplication of some kind instances
|
||||
* @run main/othervm Test4679556
|
||||
* @author Sergey Malenkov, Mark Davidson, Philip Milne
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
/**
|
||||
* Demonstrates the archiver bug, where the XMLEncoder duplicates
|
||||
* the instance of class A because it is required as the target of
|
||||
* a factory method (to produce an instance of class C).
|
||||
* See the output in the file Test.xml for the results and note
|
||||
* the (invalid) forward reference to the instance of class C.
|
||||
*
|
||||
* TO FIX
|
||||
*
|
||||
* Move the first line of the XMLEncoder::mark(Statement method)
|
||||
* to the end of the method.
|
||||
* I.e. replace the mark() method in XMLEncoder with this:
|
||||
* <pre>private void mark(Statement stm) {
|
||||
* Object[] args = stm.getArguments();
|
||||
* for (int i = 0; i < args.length; i++) {
|
||||
* Object arg = args[i];
|
||||
* mark(arg, true);
|
||||
* }
|
||||
* mark(stm.getTarget(), false);
|
||||
* }</pre>
|
||||
*
|
||||
* VALID ARCHIVE (WITH FIX):
|
||||
* <pre><?xml version="1.0" encoding="UTF-8"?>
|
||||
* <java version="1.4.0" class="java.beans.XMLDecoder">
|
||||
* <object class="TestDuplicates$A">
|
||||
* <void id="TestDuplicates$C0" method="createC"/>
|
||||
* <void property="x">
|
||||
* <void property="x">
|
||||
* <object idref="TestDuplicates$C0"/>
|
||||
* </void>
|
||||
* </void>
|
||||
* </object>
|
||||
* </java></pre>
|
||||
*
|
||||
* INVALID ARCHIVE (WITHOUT FIX):
|
||||
* <object class="TestDuplicates$A">
|
||||
* <void property="x">
|
||||
* <void property="x">
|
||||
* <void class="TestDuplicates$A">
|
||||
* <void property="x">
|
||||
* <void property="x">
|
||||
* <object idref="TestDuplicates$C0"/>
|
||||
* </void>
|
||||
* </void>
|
||||
* <void id="TestDuplicates$C0" method="createC"/>
|
||||
* </void>
|
||||
* <object idref="TestDuplicates$C0"/>
|
||||
* </void>
|
||||
* </void>
|
||||
* <void id="TestDuplicates$C0" method="createC"/>
|
||||
* </object>
|
||||
* </java></pre>
|
||||
*/
|
||||
public class Test4679556 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test4679556().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
A a = new A();
|
||||
B b = (B) a.getX();
|
||||
b.setX(a.createC());
|
||||
return a;
|
||||
}
|
||||
|
||||
protected Object getAnotherObject() {
|
||||
return new A();
|
||||
}
|
||||
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
encoder.setPersistenceDelegate(C.class, new DefaultPersistenceDelegate() {
|
||||
protected Expression instantiate(Object oldInstance, Encoder out) {
|
||||
C c = (C) oldInstance;
|
||||
return new Expression(c, c.getX(), "createC", new Object[] {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class Base {
|
||||
private Object x;
|
||||
|
||||
public Object getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(Object x) {
|
||||
this.x = x;
|
||||
}
|
||||
}
|
||||
|
||||
public static class A extends Base {
|
||||
public A() {
|
||||
setX(new B());
|
||||
}
|
||||
|
||||
public C createC() {
|
||||
return new C(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class B extends Base {
|
||||
}
|
||||
|
||||
public static class C extends Base {
|
||||
private C(Object x) {
|
||||
setX(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
82
test/jdk/java/beans/XMLEncoder/Test4822050.java
Normal file
82
test/jdk/java/beans/XMLEncoder/Test4822050.java
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 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 4822050
|
||||
* @run main/timeout=1000 Test4822050
|
||||
* @summary Tests concurrent decoding
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.ExceptionListener;
|
||||
import java.beans.XMLDecoder;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class Test4822050 implements ExceptionListener, Runnable {
|
||||
private static final int THREADS = 40;
|
||||
private static final int ATTEMPTS = 100;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
XMLEncoder encoder = new XMLEncoder(baos);
|
||||
encoder.writeObject(new JLabel("hello")); // NON-NLS: test message
|
||||
encoder.close();
|
||||
|
||||
byte[] buffer = baos.toByteArray();
|
||||
for (int i = 0; i < THREADS; i++)
|
||||
start(buffer);
|
||||
}
|
||||
|
||||
private static void start(byte[] buffer) {
|
||||
Thread thread = new Thread(new Test4822050(buffer));
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
||||
private byte[] buffer;
|
||||
|
||||
public Test4822050(byte[] buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
public void exceptionThrown(Exception exception) {
|
||||
throw new Error(exception);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for (int i = 0; i < ATTEMPTS; i++)
|
||||
parse();
|
||||
}
|
||||
|
||||
private void parse() {
|
||||
XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(this.buffer));
|
||||
decoder.readObject();
|
||||
decoder.close();
|
||||
}
|
||||
}
|
||||
923
test/jdk/java/beans/XMLEncoder/Test4880633.java
Normal file
923
test/jdk/java/beans/XMLEncoder/Test4880633.java
Normal file
|
|
@ -0,0 +1,923 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2007, 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 4880633
|
||||
* @summary Tests multi threaded access to the XMLEncoder
|
||||
* @author Mark Davidson
|
||||
*/
|
||||
|
||||
import java.beans.ExceptionListener;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class Test4880633 implements ExceptionListener, Runnable {
|
||||
private static final int THREADS_COUNT = 10;
|
||||
private static final int THREAD_LENGTH = 90;
|
||||
|
||||
public static void main(String[] args) {
|
||||
Runnable[] tests = new Runnable[THREADS_COUNT];
|
||||
for (int i = 0; i < tests.length; i++) {
|
||||
ValueObject object = new ValueObject();
|
||||
object.setA("Value a" + i);
|
||||
object.setAa("Value aa" + i);
|
||||
object.setAaa("Value aaa" + i);
|
||||
object.setAaaa("Value aaaa" + i);
|
||||
object.setAaaaa("Value aaaaa" + i);
|
||||
object.setAaaaaa("Value aaaaaa" + i);
|
||||
object.setAaaaaaa("Value aaaaaaa" + i);
|
||||
object.setAaaaaaaa("Value aaaaaaaa" + i);
|
||||
object.setAaaaaaaaa("Value aaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaa("Value aaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaa("Value aaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaa("Value aaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaa("Value aaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaa("Value aaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
object.setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa("Value aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + i);
|
||||
// set encoder thread to use this object
|
||||
tests[i] = new Test4880633(object);
|
||||
}
|
||||
//start all threads
|
||||
for (int i = 0; i < tests.length; i++) {
|
||||
Thread thread = new Thread(tests[i]);
|
||||
thread.setName("Bug Thread " + i);
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
||||
private final Object object;
|
||||
|
||||
public Test4880633(Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// run thread a few time
|
||||
// object stays the same but NullPointerException appears randomly
|
||||
// on dual proccessor a lock is generated
|
||||
for (int i = 0; i < THREAD_LENGTH; i++) {
|
||||
// create XMLEncoder to ByteArrayOutputStream
|
||||
// this is to exclude file locking problems
|
||||
XMLEncoder encoder = new XMLEncoder(new ByteArrayOutputStream());
|
||||
encoder.setExceptionListener(this);
|
||||
// write the object
|
||||
// will see randomly null pointer exceptions
|
||||
// a bug as object is same through different encode phases
|
||||
encoder.writeObject(this.object);
|
||||
//close encoder
|
||||
encoder.close();
|
||||
}
|
||||
System.out.println(Thread.currentThread().getName() + " is finished");
|
||||
}
|
||||
|
||||
public void exceptionThrown(Exception exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
|
||||
public static class ValueObject {
|
||||
private String a;
|
||||
|
||||
public void setA(String a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public String getA() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
|
||||
private String aa;
|
||||
|
||||
public void setAa(String a) {
|
||||
this.aa = a;
|
||||
}
|
||||
|
||||
public String getAa() {
|
||||
return this.aa;
|
||||
}
|
||||
|
||||
|
||||
private String aaa;
|
||||
|
||||
public void setAaa(String a) {
|
||||
this.aaa = a;
|
||||
}
|
||||
|
||||
public String getAaa() {
|
||||
return this.aaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaa;
|
||||
|
||||
public void setAaaa(String a) {
|
||||
this.aaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaa() {
|
||||
return this.aaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaa;
|
||||
|
||||
public void setAaaaa(String a) {
|
||||
this.aaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaa() {
|
||||
return this.aaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaa;
|
||||
|
||||
public void setAaaaaa(String a) {
|
||||
this.aaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaa() {
|
||||
return this.aaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaa;
|
||||
|
||||
public void setAaaaaaa(String a) {
|
||||
this.aaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaa() {
|
||||
return this.aaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaa;
|
||||
|
||||
public void setAaaaaaaa(String a) {
|
||||
this.aaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaa() {
|
||||
return this.aaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaa(String a) {
|
||||
this.aaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaa() {
|
||||
return this.aaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaa() {
|
||||
return this.aaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
|
||||
|
||||
private String aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
public void setAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(String a) {
|
||||
this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = a;
|
||||
}
|
||||
|
||||
public String getAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa() {
|
||||
return this.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
}
|
||||
}
|
||||
}
|
||||
74
test/jdk/java/beans/XMLEncoder/Test4903007.java
Normal file
74
test/jdk/java/beans/XMLEncoder/Test4903007.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2024, 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 4903007 6972468
|
||||
* @summary Tests encoding of container with boxes and BoxLayout
|
||||
* @run main/othervm Test4903007
|
||||
* @author Sergey Malenkov, Mark Davidson
|
||||
*/
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Test4903007 extends AbstractTest<JPanel> {
|
||||
public static void main(String[] args) throws Exception {
|
||||
new Test4903007().test();
|
||||
}
|
||||
|
||||
protected JPanel getObject() {
|
||||
Box vBox = Box.createVerticalBox();
|
||||
vBox.add(new JButton("button"));
|
||||
vBox.add(Box.createVerticalStrut(10));
|
||||
vBox.add(new JLabel("label"));
|
||||
vBox.add(Box.createVerticalGlue());
|
||||
vBox.add(new JButton("button"));
|
||||
vBox.add(Box.createVerticalStrut(10));
|
||||
vBox.add(new JLabel("label"));
|
||||
|
||||
Box hBox = Box.createHorizontalBox();
|
||||
hBox.add(new JButton("button"));
|
||||
hBox.add(Box.createHorizontalStrut(10));
|
||||
hBox.add(new JLabel("label"));
|
||||
hBox.add(Box.createHorizontalGlue());
|
||||
hBox.add(new JButton("button"));
|
||||
hBox.add(Box.createHorizontalStrut(10));
|
||||
hBox.add(new JLabel("label"));
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
panel.add(vBox);
|
||||
panel.add(Box.createGlue());
|
||||
panel.add(hBox);
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected JPanel getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return new JPanel();
|
||||
}
|
||||
}
|
||||
84
test/jdk/java/beans/XMLEncoder/Test4935607.java
Normal file
84
test/jdk/java/beans/XMLEncoder/Test4935607.java
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 %I% %G%
|
||||
* @bug 4935607
|
||||
* @summary Tests transient properties
|
||||
* @run main/othervm Test4935607
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Transient;
|
||||
|
||||
public class Test4935607 extends AbstractTest<Test4935607.TransientBean> {
|
||||
public static void main(String[] args) {
|
||||
new Test4935607().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TransientBean getObject() {
|
||||
TransientBean bean = new TransientBean();
|
||||
bean.setName("some string"); // NON-NLS: some string
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TransientBean getAnotherObject() {
|
||||
TransientBean bean = new TransientBean();
|
||||
bean.setName("another string"); // NON-NLS: another string
|
||||
bean.setComment("some comment"); // NON-NLS: some comment
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate(TransientBean before, TransientBean after) {
|
||||
if (!before.getName().equals(after.getName()))
|
||||
throw new Error("the name property incorrectly encoded");
|
||||
|
||||
if (null != after.getComment())
|
||||
throw new Error("the comment property should be encoded");
|
||||
}
|
||||
|
||||
public static class TransientBean {
|
||||
private String name;
|
||||
private String comment;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
}
|
||||
}
|
||||
91
test/jdk/java/beans/XMLEncoder/Test4936682.java
Normal file
91
test/jdk/java/beans/XMLEncoder/Test4936682.java
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 4936682
|
||||
* @summary Tests encoding of reference to target
|
||||
* @run main/othervm Test4936682
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
public final class Test4936682 extends AbstractTest<Object[]> {
|
||||
public static void main(String[] args) {
|
||||
new Test4936682().test();
|
||||
}
|
||||
|
||||
protected Object[] getObject() {
|
||||
OuterClass outer = new OuterClass();
|
||||
return new Object [] {outer.getInner(), outer};
|
||||
}
|
||||
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
encoder.setPersistenceDelegate(
|
||||
OuterClass.InnerClass.class,
|
||||
new DefaultPersistenceDelegate() {
|
||||
protected Expression instantiate(Object oldInstance, Encoder out) {
|
||||
OuterClass.InnerClass inner = (OuterClass.InnerClass) oldInstance;
|
||||
OuterClass outer = inner.getOuter();
|
||||
return new Expression(inner, outer, "getInner", new Object[0]);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected void validate(Object[] before, Object[] after) {
|
||||
validate(before);
|
||||
validate(after);
|
||||
}
|
||||
|
||||
private static void validate(Object[] array) {
|
||||
if (2 != array.length) {
|
||||
throw new Error("unexpected array length: " + array.length);
|
||||
}
|
||||
OuterClass outer = (OuterClass) array[1];
|
||||
if (!outer.getInner().equals(array[0])) {
|
||||
throw new Error("unexpected array content");
|
||||
}
|
||||
}
|
||||
|
||||
public static final class OuterClass {
|
||||
private final InnerClass inner = new InnerClass();
|
||||
|
||||
public InnerClass getInner() {
|
||||
return this.inner;
|
||||
}
|
||||
|
||||
public class InnerClass {
|
||||
private InnerClass() {
|
||||
}
|
||||
|
||||
public OuterClass getOuter() {
|
||||
return OuterClass.this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
test/jdk/java/beans/XMLEncoder/Test4950122.java
Normal file
75
test/jdk/java/beans/XMLEncoder/Test4950122.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2007, 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 4950122
|
||||
* @summary Tests DefaultPersistenceDelegate with boolean and integer property
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.ExceptionListener;
|
||||
import java.beans.Expression;
|
||||
|
||||
public final class Test4950122 {
|
||||
public static void main(String[] args) {
|
||||
TestBean bean = new TestBean(true, 11);
|
||||
Encoder encoder = new Encoder();
|
||||
encoder.setExceptionListener(bean);
|
||||
new TestDPD().instantiate(bean, encoder);
|
||||
}
|
||||
|
||||
public static class TestDPD extends DefaultPersistenceDelegate {
|
||||
public TestDPD() {
|
||||
super(new String[] {"boolean", "integer"});
|
||||
}
|
||||
|
||||
public Expression instantiate(Object oldInstance, Encoder out) {
|
||||
return super.instantiate(oldInstance, out);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TestBean implements ExceptionListener {
|
||||
private boolean b;
|
||||
private int i;
|
||||
|
||||
public TestBean(boolean b, int i) {
|
||||
this.b = b;
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public boolean isBoolean() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public int getInteger() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
public void exceptionThrown(Exception exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
test/jdk/java/beans/XMLEncoder/Test4968523.java
Normal file
59
test/jdk/java/beans/XMLEncoder/Test4968523.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2007, 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 4968523
|
||||
* @summary Tests persistence delegate in different encoders
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.util.Date;
|
||||
|
||||
public class Test4968523 {
|
||||
public static void main(String[] args) {
|
||||
String[] names = {"time"};
|
||||
test(Date.class, new DefaultPersistenceDelegate(names));
|
||||
test(null, new DefaultPersistenceDelegate());
|
||||
}
|
||||
|
||||
private static void test(Class<?> type, PersistenceDelegate pd) {
|
||||
Encoder encoder1 = new Encoder();
|
||||
Encoder encoder2 = new XMLEncoder(System.out);
|
||||
|
||||
PersistenceDelegate pd1 = encoder1.getPersistenceDelegate(type);
|
||||
PersistenceDelegate pd2 = encoder2.getPersistenceDelegate(type);
|
||||
|
||||
encoder1.setPersistenceDelegate(type, pd);
|
||||
|
||||
if (pd1 == encoder1.getPersistenceDelegate(type))
|
||||
throw new Error("first persistence delegate is not changed");
|
||||
|
||||
if (pd2 != encoder2.getPersistenceDelegate(type))
|
||||
throw new Error("second persistence delegate is changed");
|
||||
}
|
||||
}
|
||||
102
test/jdk/java/beans/XMLEncoder/Test4993777.java
Normal file
102
test/jdk/java/beans/XMLEncoder/Test4993777.java
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4993777
|
||||
* @summary Tests encoding of multi-dimensional arrays
|
||||
* @run main/othervm Test4993777
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class Test4993777 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test4993777().test();
|
||||
}
|
||||
|
||||
protected ArrayBean getObject() {
|
||||
ArrayBean data = new ArrayBean();
|
||||
data.setArray(
|
||||
new InnerObject("one"),
|
||||
new InnerObject("two")
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
protected ArrayBean getAnotherObject() {
|
||||
ArrayBean data = new ArrayBean();
|
||||
data.setArray2D(
|
||||
new InnerObject[] {
|
||||
new InnerObject("1"),
|
||||
new InnerObject("2"),
|
||||
new InnerObject("3"),
|
||||
},
|
||||
new InnerObject[] {
|
||||
new InnerObject("4"),
|
||||
new InnerObject("5"),
|
||||
new InnerObject("6"),
|
||||
}
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static final class ArrayBean {
|
||||
private InnerObject[] array;
|
||||
private InnerObject[][] array2D;
|
||||
|
||||
public InnerObject[] getArray() {
|
||||
return this.array;
|
||||
}
|
||||
|
||||
public void setArray(InnerObject... array) {
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public InnerObject[][] getArray2D() {
|
||||
return this.array2D;
|
||||
}
|
||||
|
||||
public void setArray2D(InnerObject[]... array2D) {
|
||||
this.array2D = array2D;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class InnerObject {
|
||||
private String name;
|
||||
|
||||
public InnerObject() {
|
||||
}
|
||||
|
||||
private InnerObject(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
59
test/jdk/java/beans/XMLEncoder/Test4994637.java
Normal file
59
test/jdk/java/beans/XMLEncoder/Test4994637.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2024, 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 4994637
|
||||
* @summary Tests custom map encoding
|
||||
* @run main/othervm Test4994637
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class Test4994637 extends AbstractTest<HashMap> {
|
||||
public static void main(String[] args) {
|
||||
new Test4994637().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CustomMap getObject() {
|
||||
return new CustomMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CustomMap getAnotherObject() {
|
||||
CustomMap map = new CustomMap();
|
||||
map.clear();
|
||||
map.put(null, "zero");
|
||||
return map;
|
||||
}
|
||||
|
||||
public static final class CustomMap extends HashMap<String, String> {
|
||||
public CustomMap() {
|
||||
put("1", "one");
|
||||
put("2", "two");
|
||||
put("3", "three");
|
||||
}
|
||||
}
|
||||
}
|
||||
123
test/jdk/java/beans/XMLEncoder/Test5023550.java
Normal file
123
test/jdk/java/beans/XMLEncoder/Test5023550.java
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 5023550
|
||||
* @summary Tests complex references to owner
|
||||
* @run main/othervm Test5023550
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.XMLDecoder;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
public class Test5023550 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test5023550().test();
|
||||
}
|
||||
|
||||
private final Owner owner = new Owner();
|
||||
|
||||
@Override
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
encoder.setOwner(this.owner);
|
||||
encoder.setPersistenceDelegate(A.class, new ADelegate());
|
||||
encoder.setPersistenceDelegate(B.class, new BDelegate());
|
||||
encoder.setPersistenceDelegate(C.class, new CDelegate());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize(XMLDecoder decoder) {
|
||||
decoder.setOwner(this.owner);
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return this.owner.newA(this.owner.newB().newC());
|
||||
}
|
||||
|
||||
public static class Owner {
|
||||
public A newA(C c) {
|
||||
return new A(c);
|
||||
}
|
||||
|
||||
public B newB() {
|
||||
return new B();
|
||||
}
|
||||
}
|
||||
|
||||
public static class A {
|
||||
private final C c;
|
||||
|
||||
private A(C c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public C getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
public static class B {
|
||||
public C newC() {
|
||||
return new C(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class C {
|
||||
private final B b;
|
||||
|
||||
private C(B b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public B getB() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ADelegate extends DefaultPersistenceDelegate {
|
||||
protected Expression instantiate(Object old, Encoder out) {
|
||||
XMLEncoder encoder = (XMLEncoder) out;
|
||||
A a = (A) old;
|
||||
return new Expression(old, encoder.getOwner(), "newA", new Object[] { a.getC() });
|
||||
}
|
||||
}
|
||||
|
||||
public static class BDelegate extends DefaultPersistenceDelegate {
|
||||
protected Expression instantiate(Object old, Encoder out) {
|
||||
XMLEncoder encoder = (XMLEncoder) out;
|
||||
return new Expression(old, encoder.getOwner(), "newB", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CDelegate extends DefaultPersistenceDelegate {
|
||||
protected Expression instantiate(Object old, Encoder out) {
|
||||
C c = (C) old;
|
||||
return new Expression(c, c.getB(), "newC", new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
74
test/jdk/java/beans/XMLEncoder/Test5023552.java
Normal file
74
test/jdk/java/beans/XMLEncoder/Test5023552.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 5023552
|
||||
* @summary Tests reference count updating
|
||||
* @run main/othervm Test5023552
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
public final class Test5023552 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test5023552().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
Component component = new Component();
|
||||
return component.create(component);
|
||||
}
|
||||
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
encoder.setPersistenceDelegate(Container.class, new PersistenceDelegate() {
|
||||
protected Expression instantiate(Object oldInstance, Encoder out) {
|
||||
Container container = (Container) oldInstance;
|
||||
Component component = container.getComponent();
|
||||
return new Expression(container, component, "create", new Object[] {component});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static final class Component {
|
||||
public Container create(Component component) {
|
||||
return new Container(component);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Container {
|
||||
private final Component component;
|
||||
|
||||
public Container(Component component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public Component getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
}
|
||||
}
|
||||
100
test/jdk/java/beans/XMLEncoder/Test5023557.java
Normal file
100
test/jdk/java/beans/XMLEncoder/Test5023557.java
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 5023557
|
||||
* @summary Tests complex references
|
||||
* @run main/othervm Test5023557
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
public class Test5023557 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test5023557().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
encoder.setPersistenceDelegate(B.class, new BDelegate());
|
||||
encoder.setPersistenceDelegate(C.class, new CDelegate());
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
A a = new A();
|
||||
return a.newC(a.newB());
|
||||
}
|
||||
|
||||
public static class A {
|
||||
public B newB() {
|
||||
return new B(this);
|
||||
}
|
||||
|
||||
public C newC(B b) {
|
||||
return new C(b);
|
||||
}
|
||||
}
|
||||
|
||||
public static class B {
|
||||
private final A a;
|
||||
|
||||
private B(A a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public A getA() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
|
||||
public static class C {
|
||||
private final B b;
|
||||
|
||||
private C(B b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public B getB() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BDelegate extends DefaultPersistenceDelegate {
|
||||
protected Expression instantiate(Object old, Encoder out) {
|
||||
B b = (B) old;
|
||||
return new Expression(b, b.getA(), "newB", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CDelegate extends DefaultPersistenceDelegate {
|
||||
protected Expression instantiate(Object old, Encoder out) {
|
||||
C c = (C) old;
|
||||
return new Expression(c, c.getB().getA(), "newC", new Object[] { c.getB() });
|
||||
}
|
||||
}
|
||||
}
|
||||
94
test/jdk/java/beans/XMLEncoder/Test5023559.java
Normal file
94
test/jdk/java/beans/XMLEncoder/Test5023559.java
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 5023559
|
||||
* @summary Tests encoding of the object with nested target
|
||||
* @run main/othervm Test5023559
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
public final class Test5023559 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test5023559().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return new GrandParent().create().create();
|
||||
}
|
||||
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
encoder.setPersistenceDelegate(Parent.class, new PersistenceDelegate() {
|
||||
protected Expression instantiate(Object old, Encoder out) {
|
||||
Parent parent = (Parent) old;
|
||||
return new Expression(old, parent.getParent(), "create", new Object[] {});
|
||||
}
|
||||
});
|
||||
encoder.setPersistenceDelegate(Child.class, new PersistenceDelegate() {
|
||||
protected Expression instantiate(Object old, Encoder out) {
|
||||
Child child = (Child) old;
|
||||
return new Expression(old, child.getParent(), "create", new Object[] {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static final class GrandParent {
|
||||
public Parent create() {
|
||||
return new Parent(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Parent {
|
||||
private final GrandParent parent;
|
||||
|
||||
private Parent(GrandParent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public GrandParent getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public Child create() {
|
||||
return new Child(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Child {
|
||||
private final Parent parent;
|
||||
|
||||
private Child(Parent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Parent getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
66
test/jdk/java/beans/XMLEncoder/Test6176120.java
Normal file
66
test/jdk/java/beans/XMLEncoder/Test6176120.java
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6176120
|
||||
* @summary Tests bean that contains constructor marked with ConstructorProperties annotation
|
||||
* @run main/othervm Test6176120
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
public final class Test6176120 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6176120().test();
|
||||
}
|
||||
|
||||
protected ImmutableBean getObject() {
|
||||
return new ImmutableBean(1, -1);
|
||||
}
|
||||
|
||||
protected ImmutableBean getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return new ImmutableBean(-1, 1);
|
||||
}
|
||||
|
||||
public static final class ImmutableBean {
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
@ConstructorProperties({"x", "y"})
|
||||
public ImmutableBean( int x, int y ) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
138
test/jdk/java/beans/XMLEncoder/Test6187118.java
Normal file
138
test/jdk/java/beans/XMLEncoder/Test6187118.java
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6187118
|
||||
* @summary Tests encoding of immutable list that creates itself
|
||||
* @run main/othervm Test6187118
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.XMLEncoder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public final class Test6187118 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6187118().test();
|
||||
}
|
||||
|
||||
protected ImmutableList<String> getObject() {
|
||||
return new ImmutableList<String>();
|
||||
}
|
||||
|
||||
protected ImmutableList<String> getAnotherObject() {
|
||||
return new ImmutableList<String>().add("1").add("2").add("3").add("4");
|
||||
}
|
||||
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
encoder.setPersistenceDelegate(
|
||||
ImmutableList.class,
|
||||
new PersistenceDelegate() {
|
||||
protected boolean mutatesTo(Object oldInstance, Object newInstance) {
|
||||
return oldInstance.equals(newInstance);
|
||||
}
|
||||
|
||||
protected Expression instantiate(Object oldInstance, Encoder out) {
|
||||
ImmutableList list = (ImmutableList) oldInstance;
|
||||
if (!list.hasEntries()) {
|
||||
return getExpression(oldInstance, ImmutableList.class, "new");
|
||||
}
|
||||
Object object = list.getLast();
|
||||
ImmutableList shortenedList = list.removeLast();
|
||||
return getExpression(oldInstance, shortenedList, "add", object);
|
||||
}
|
||||
|
||||
private Expression getExpression(Object value, Object target, String method, Object... args) {
|
||||
return new Expression(value, target, method, args);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static final class ImmutableList<T> implements Iterable {
|
||||
private final List<T> list = new ArrayList<T>();
|
||||
|
||||
public ImmutableList() {
|
||||
}
|
||||
|
||||
private ImmutableList(Iterable<T> iterable) {
|
||||
for (T object : iterable) {
|
||||
this.list.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return Collections.unmodifiableList(this.list).iterator();
|
||||
}
|
||||
|
||||
public ImmutableList<T> add(T object) {
|
||||
ImmutableList<T> list = new ImmutableList<T>(this.list);
|
||||
list.list.add(object);
|
||||
return list;
|
||||
}
|
||||
|
||||
public ImmutableList<T> removeLast() {
|
||||
ImmutableList<T> list = new ImmutableList<T>(this.list);
|
||||
int size = list.list.size();
|
||||
if (0 < size) {
|
||||
list.list.remove(size - 1);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public T getLast() {
|
||||
int size = this.list.size();
|
||||
return (0 < size)
|
||||
? this.list.get(size - 1)
|
||||
: null;
|
||||
}
|
||||
|
||||
public boolean hasEntries() {
|
||||
return 0 < this.list.size();
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof ImmutableList) {
|
||||
ImmutableList list = (ImmutableList) object;
|
||||
return this.list.equals(list.list);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.list.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.list.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
79
test/jdk/java/beans/XMLEncoder/Test6256805.java
Normal file
79
test/jdk/java/beans/XMLEncoder/Test6256805.java
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6256805
|
||||
* @summary Tests invalid XML characters encoding
|
||||
* @run main/othervm Test6256805
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class Test6256805 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6256805().test();
|
||||
}
|
||||
|
||||
protected CharacterBean getObject() {
|
||||
CharacterBean bean = new CharacterBean();
|
||||
bean.setString("\u0000\ud800\udc00\uFFFF");
|
||||
return bean;
|
||||
}
|
||||
|
||||
protected CharacterBean getAnotherObject() {
|
||||
CharacterBean bean = new CharacterBean();
|
||||
bean.setPrimitive('\uD800');
|
||||
bean.setChar(Character.valueOf('\u001F'));
|
||||
return bean;
|
||||
}
|
||||
|
||||
public static final class CharacterBean {
|
||||
private char primitive;
|
||||
private Character character;
|
||||
private String string;
|
||||
|
||||
public char getPrimitive() {
|
||||
return this.primitive;
|
||||
}
|
||||
|
||||
public void setPrimitive( char primitive ) {
|
||||
this.primitive = primitive;
|
||||
}
|
||||
|
||||
public Character getChar() {
|
||||
return this.character;
|
||||
}
|
||||
|
||||
public void setChar( Character character ) {
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return this.string;
|
||||
}
|
||||
|
||||
public void setString( String string ) {
|
||||
this.string = string;
|
||||
}
|
||||
}
|
||||
}
|
||||
87
test/jdk/java/beans/XMLEncoder/Test6437265.java
Normal file
87
test/jdk/java/beans/XMLEncoder/Test6437265.java
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6437265
|
||||
* @summary Tests encoding of container with BorderLayout
|
||||
* @run main/othervm Test6437265
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public final class Test6437265 extends AbstractTest<JPanel> {
|
||||
private static final String[] NAMES = {
|
||||
BorderLayout.EAST,
|
||||
BorderLayout.WEST,
|
||||
BorderLayout.NORTH,
|
||||
BorderLayout.SOUTH,
|
||||
BorderLayout.CENTER,
|
||||
BorderLayout.LINE_END,
|
||||
BorderLayout.PAGE_END,
|
||||
BorderLayout.LINE_START,
|
||||
BorderLayout.PAGE_START};
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Test6437265().test();
|
||||
}
|
||||
|
||||
protected JPanel getObject() {
|
||||
JPanel panel = new MyPanel();
|
||||
for (String name : NAMES) {
|
||||
panel.add(name, new JLabel(name));
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected void validate(JPanel before, JPanel after) {
|
||||
validate(before);
|
||||
validate(after);
|
||||
super.validate(before, after);
|
||||
}
|
||||
|
||||
private static void validate(JPanel panel) {
|
||||
BorderLayout layout = (BorderLayout) panel.getLayout();
|
||||
for (Component component : panel.getComponents()) {
|
||||
String name = (String) layout.getConstraints(component);
|
||||
if (name == null)
|
||||
throw new Error("The component is not layed out: " + component);
|
||||
|
||||
JLabel label = (JLabel) component;
|
||||
if (!name.equals(label.getText()))
|
||||
throw new Error("The component is layed out on " + name + ": " + component);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class MyPanel extends JPanel {
|
||||
public MyPanel() {
|
||||
// the bug is reproducible for containers
|
||||
// that uses BorderLayout as default layout manager.
|
||||
super(new BorderLayout(3, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
49
test/jdk/java/beans/XMLEncoder/Test6501431.java
Normal file
49
test/jdk/java/beans/XMLEncoder/Test6501431.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6501431
|
||||
* @summary Tests encoding of JMenuItem with accelerator property
|
||||
* @run main/othervm Test6501431
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
public final class Test6501431 extends AbstractTest<JMenuItem> {
|
||||
public static void main(String[] args) {
|
||||
new Test6501431().test();
|
||||
}
|
||||
|
||||
protected JMenuItem getObject() {
|
||||
JMenuItem menu = new JMenuItem();
|
||||
menu.setAccelerator(KeyStroke.getKeyStroke("ctrl F2"));
|
||||
return menu;
|
||||
}
|
||||
|
||||
protected JMenuItem getAnotherObject() {
|
||||
return new JMenuItem();
|
||||
}
|
||||
}
|
||||
67
test/jdk/java/beans/XMLEncoder/Test6505888.java
Normal file
67
test/jdk/java/beans/XMLEncoder/Test6505888.java
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests bean with the property that is guarded by UnmodifiableList
|
||||
* @run main/othervm Test6505888
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class Test6505888 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6505888().test();
|
||||
}
|
||||
|
||||
protected ListBean getObject() {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
list.add(Integer.valueOf(26));
|
||||
list.add(Integer.valueOf(10));
|
||||
list.add(Integer.valueOf(74));
|
||||
return new ListBean(list);
|
||||
}
|
||||
|
||||
protected ListBean getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return new ListBean(new ArrayList<Integer>());
|
||||
}
|
||||
|
||||
public static final class ListBean {
|
||||
private List<Integer> list;
|
||||
|
||||
@ConstructorProperties("list")
|
||||
public ListBean(List<Integer> list) {
|
||||
this.list = new ArrayList<Integer>(list);
|
||||
}
|
||||
|
||||
public List<Integer> getList() {
|
||||
return Collections.unmodifiableList(this.list);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
test/jdk/java/beans/XMLEncoder/Test6531597.java
Normal file
49
test/jdk/java/beans/XMLEncoder/Test6531597.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6531597
|
||||
* @summary Tests encoding of arrays of primitives
|
||||
* @run main/othervm Test6531597
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class Test6531597 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6531597().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return new Object[] {
|
||||
new byte[] {0, 1, 2},
|
||||
new short[] {0, 1, 2, 3, 4},
|
||||
new int[] {0, 1, 2, 3, 4, 5, 6},
|
||||
new long[] {0, 1, 2, 3, 4, 5, 6, 7, 8},
|
||||
new float[] {0.0f, 1.1f, 2.2f},
|
||||
new double[] {0.0, 1.1, 2.2, 3.3, 4.4},
|
||||
new char[] {'a', 'b', 'c'},
|
||||
new boolean[] {true, false},
|
||||
};
|
||||
}
|
||||
}
|
||||
49
test/jdk/java/beans/XMLEncoder/Test6570354.java
Normal file
49
test/jdk/java/beans/XMLEncoder/Test6570354.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6570354
|
||||
* @summary Tests listeners removing
|
||||
* @run main/othervm Test6570354
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public final class Test6570354 extends AbstractTest<JLabel> {
|
||||
public static void main(String[] args) {
|
||||
new Test6570354().test();
|
||||
}
|
||||
|
||||
protected JLabel getObject() {
|
||||
JLabel label = new JLabel("");
|
||||
label.removePropertyChangeListener((PropertyChangeListener) label.getUI());
|
||||
return label;
|
||||
}
|
||||
|
||||
protected JLabel getAnotherObject() {
|
||||
return new JLabel("");
|
||||
}
|
||||
}
|
||||
59
test/jdk/java/beans/XMLEncoder/Test6852574.java
Normal file
59
test/jdk/java/beans/XMLEncoder/Test6852574.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2024, 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 6852574
|
||||
* @summary Tests Enum subclass encoding
|
||||
* @run main/othervm Test6852574
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class Test6852574 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6852574().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return Data.FIRST;
|
||||
}
|
||||
|
||||
protected Object getAnotherObject() {
|
||||
return Data.SECOND;
|
||||
}
|
||||
|
||||
public enum Data {
|
||||
FIRST {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
},
|
||||
SECOND {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "2";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
198
test/jdk/java/beans/XMLEncoder/Test6921644.java
Normal file
198
test/jdk/java/beans/XMLEncoder/Test6921644.java
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 6921644
|
||||
* @summary Tests references to cached integer
|
||||
* @run main/othervm Test6921644
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class Test6921644 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6921644().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
Owner<Author> o = new Owner<Author>(100); // it works if ID >= 128
|
||||
|
||||
Category c = new Category(o);
|
||||
|
||||
Document d1 = new Document(o);
|
||||
Document d2 = new Document(o);
|
||||
Document d3 = new Document(o);
|
||||
|
||||
Author a1 = new Author(o);
|
||||
Author a2 = new Author(o);
|
||||
Author a3 = new Author(o);
|
||||
|
||||
o.getList().add(a1);
|
||||
o.getList().add(a2);
|
||||
o.getList().add(a3);
|
||||
|
||||
a3.setRef(o.getId());
|
||||
|
||||
d2.setCategory(c);
|
||||
d3.setCategory(c);
|
||||
|
||||
a1.addDocument(d1);
|
||||
a1.addDocument(d2);
|
||||
a3.addDocument(d3);
|
||||
|
||||
c.addDocument(d2);
|
||||
c.addDocument(d3);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public static class Owner<T> {
|
||||
private int id;
|
||||
private List<T> list = new ArrayList<T>();
|
||||
|
||||
@ConstructorProperties("id")
|
||||
public Owner(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public void setList(List<T> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Author {
|
||||
private int id;
|
||||
private int ref;
|
||||
private Owner owner;
|
||||
private List<Document> list = new ArrayList<Document>();
|
||||
|
||||
@ConstructorProperties("owner")
|
||||
public Author(Owner<Author> owner) {
|
||||
this.owner = owner;
|
||||
this.id = owner.getId();
|
||||
}
|
||||
|
||||
public Owner getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getRef() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
public void setRef(Integer ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
public List<Document> getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public void setList(List<Document> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public void addDocument(Document document) {
|
||||
this.list.add(document);
|
||||
document.setAuthor(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Category {
|
||||
private Owner owner;
|
||||
private List<Document> list = new ArrayList<Document>();
|
||||
|
||||
@ConstructorProperties("owner")
|
||||
public Category(Owner owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Owner getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
public List<Document> getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public void setList(List<Document> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public void addDocument(Document document) {
|
||||
this.list.add(document);
|
||||
document.setCategory(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Document {
|
||||
private Owner owner;
|
||||
private Author author;
|
||||
private Category category;
|
||||
|
||||
@ConstructorProperties("owner")
|
||||
public Document(Owner owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Owner getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
public Author getAuthor() {
|
||||
return this.author;
|
||||
}
|
||||
|
||||
public void setAuthor(Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
}
|
||||
84
test/jdk/java/beans/XMLEncoder/Test6963811.java
Normal file
84
test/jdk/java/beans/XMLEncoder/Test6963811.java
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 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 6963811
|
||||
* @summary Tests deadlock in Encoder
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Encoder;
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
|
||||
public class Test6963811 implements Runnable {
|
||||
private static final Encoder ENCODER = new Encoder();
|
||||
private final long time;
|
||||
private final boolean sync;
|
||||
|
||||
public Test6963811(long time, boolean sync) {
|
||||
this.time = time;
|
||||
this.sync = sync;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(this.time); // increase the chance of the deadlock
|
||||
if (this.sync) {
|
||||
synchronized (Test6963811.class) {
|
||||
ENCODER.getPersistenceDelegate(Super.class);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ENCODER.getPersistenceDelegate(Sub.class);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Thread[] threads = new Thread[2];
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
threads[i] = new Thread(new Test6963811(0L, i > 0));
|
||||
threads[i].start();
|
||||
Thread.sleep(500L); // increase the chance of the deadlock
|
||||
}
|
||||
for (Thread thread : threads) {
|
||||
thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Super {
|
||||
}
|
||||
|
||||
public static class Sub extends Super {
|
||||
}
|
||||
|
||||
public static class SubPersistenceDelegate extends DefaultPersistenceDelegate {
|
||||
public SubPersistenceDelegate() {
|
||||
new Test6963811(1000L, true).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
61
test/jdk/java/beans/XMLEncoder/Test6989223.java
Normal file
61
test/jdk/java/beans/XMLEncoder/Test6989223.java
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 6989223
|
||||
* @summary Tests Rectangle2D.Double encoding
|
||||
* @run main/othervm Test6989223
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
public class Test6989223 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test6989223().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return new Bean(1, 2, 3, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAnotherObject() {
|
||||
return new Bean(1, 2, 3, 5);
|
||||
}
|
||||
|
||||
public static class Bean extends Rectangle2D.Double {
|
||||
public Bean() {
|
||||
}
|
||||
|
||||
public Bean(double x, double y, double w, double h) {
|
||||
super(x, y, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return super.equals(object); // to avoid recursion during validation
|
||||
}
|
||||
}
|
||||
}
|
||||
61
test/jdk/java/beans/XMLEncoder/Test7080156.java
Normal file
61
test/jdk/java/beans/XMLEncoder/Test7080156.java
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 7080156 7094245
|
||||
* @summary Tests beans with public arrays
|
||||
* @run main/othervm Test7080156
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public class Test7080156 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test7080156().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
Bean bean = new Bean();
|
||||
bean.setArray("something");
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAnotherObject() {
|
||||
Bean bean = new Bean();
|
||||
bean.setArray("some", "thing");
|
||||
return bean;
|
||||
}
|
||||
|
||||
public static class Bean {
|
||||
public String[] array = {"default"};
|
||||
|
||||
public void setArray(String... array) {
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public String[] getArray() {
|
||||
return this.array;
|
||||
}
|
||||
}
|
||||
}
|
||||
67
test/jdk/java/beans/XMLEncoder/Test7092744.java
Normal file
67
test/jdk/java/beans/XMLEncoder/Test7092744.java
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2024, 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 7092744
|
||||
* @summary Tests for ambiguous methods
|
||||
* @run main/othervm Test7092744
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public class Test7092744 extends AbstractTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Test7092744().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return new Bean();
|
||||
}
|
||||
|
||||
protected Object getAnotherObject() {
|
||||
Bean bean = new Bean();
|
||||
bean.setValue(99);
|
||||
return bean;
|
||||
}
|
||||
|
||||
public static interface I<T extends Number> {
|
||||
|
||||
T getValue();
|
||||
|
||||
void setValue(T value);
|
||||
}
|
||||
|
||||
public static class Bean implements I<Integer> {
|
||||
|
||||
private Integer value;
|
||||
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
102
test/jdk/java/beans/XMLEncoder/Test7169395.java
Normal file
102
test/jdk/java/beans/XMLEncoder/Test7169395.java
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2024, 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 7169395
|
||||
* @summary Tests that array list initialized correctly
|
||||
* @run main/othervm Test7169395
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class Test7169395 extends AbstractTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Test7169395().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
Container container = new Container();
|
||||
container.add("test-null", null);
|
||||
container.add("test-value", "value");
|
||||
container.add("test-other", "other");
|
||||
return container;
|
||||
}
|
||||
|
||||
public static class Component {
|
||||
|
||||
private final Container container;
|
||||
private final String name;
|
||||
private String value;
|
||||
|
||||
@ConstructorProperties({ "container", "name" })
|
||||
public Component(Container container, String name) {
|
||||
this.container = container;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Container getContainer() {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Container {
|
||||
|
||||
private final Map<String, Component> map = new TreeMap<String, Component>();
|
||||
|
||||
public Collection<Component> getComponents() {
|
||||
return new ArrayList<Component>(this.map.values());
|
||||
}
|
||||
|
||||
public void setComponents(Collection<Component> components) {
|
||||
this.map.clear();
|
||||
for (Component component : components){
|
||||
this.map.put(component.getName(), component);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String name, String value) {
|
||||
Component list = new Component(this, name);
|
||||
list.setValue(value);
|
||||
this.map.put(name, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
91
test/jdk/java/beans/XMLEncoder/Test8013416.java
Normal file
91
test/jdk/java/beans/XMLEncoder/Test8013416.java
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 8013416
|
||||
* @summary Tests public synthetic methods
|
||||
* @run main/othervm Test8013416
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.DefaultPersistenceDelegate;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.Statement;
|
||||
import java.beans.XMLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public class Test8013416 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test8013416().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
Public<String, String> map = new Public<String, String>();
|
||||
map.put(" pz1 ", " pz2 ");
|
||||
map.put(" pz3 ", " pz4 ");
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize(XMLEncoder encoder) {
|
||||
super.initialize(encoder);
|
||||
encoder.setPersistenceDelegate(Public.class, new PublicPersistenceDelegate());
|
||||
}
|
||||
|
||||
private static final class PublicPersistenceDelegate extends DefaultPersistenceDelegate {
|
||||
@Override
|
||||
protected Expression instantiate(Object oldInstance, Encoder out) {
|
||||
return new Expression(oldInstance, oldInstance.getClass(), "new", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
|
||||
super.initialize(type, oldInstance, newInstance, out);
|
||||
|
||||
Public<String, String> map = (Public) oldInstance;
|
||||
for (Entry<String, String> entry : map.getAll()) {
|
||||
String[] args = {entry.getKey(), entry.getValue()};
|
||||
out.writeStatement(new Statement(oldInstance, "put", args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Public<K, V> extends Private<K, V> {
|
||||
}
|
||||
|
||||
private static class Private<K, V> {
|
||||
private HashMap<K, V> map = new HashMap<K, V>();
|
||||
|
||||
public void put(K key, V value) {
|
||||
this.map.put(key, value);
|
||||
}
|
||||
|
||||
public Set<Entry<K, V>> getAll() {
|
||||
return this.map.entrySet();
|
||||
}
|
||||
}
|
||||
}
|
||||
85
test/jdk/java/beans/XMLEncoder/Test8013557.java
Normal file
85
test/jdk/java/beans/XMLEncoder/Test8013557.java
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 8013557
|
||||
* @summary Tests beans with public fields
|
||||
* @run main/othervm Test8013557
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public class Test8013557 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test8013557().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return new Bean(new Value("something"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAnotherObject() {
|
||||
return new Bean(new Value());
|
||||
}
|
||||
|
||||
public static class Bean {
|
||||
public Value value;
|
||||
|
||||
public Bean() {
|
||||
this.value = new Value();
|
||||
}
|
||||
|
||||
public Bean(Value value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(Value value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Value getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Value {
|
||||
private String string;
|
||||
|
||||
public Value() {
|
||||
this.string = "default";
|
||||
}
|
||||
|
||||
public Value(String value) {
|
||||
this.string = value;
|
||||
}
|
||||
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return this.string;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
test/jdk/java/beans/XMLEncoder/Test8016545.java
Normal file
107
test/jdk/java/beans/XMLEncoder/Test8016545.java
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 8016545
|
||||
* @summary Tests beans with predefined fields
|
||||
* @run main/othervm Test8016545
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public class Test8016545 extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new Test8016545().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getObject() {
|
||||
Bean bean = new Bean();
|
||||
bean.setUndefined(Boolean.FALSE);
|
||||
Info info = new Info();
|
||||
info.setEnabled(Boolean.TRUE);
|
||||
info.setID(1);
|
||||
bean.setInfo(info);
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getAnotherObject() {
|
||||
Bean bean = new Bean();
|
||||
bean.setUndefined(Boolean.TRUE);
|
||||
bean.getInfo().setEnabled(Boolean.FALSE);
|
||||
bean.getInfo().setID(2);
|
||||
return bean;
|
||||
}
|
||||
|
||||
public static class Bean {
|
||||
private Info info = new Info(); // predefined
|
||||
private Boolean defined = Boolean.TRUE;
|
||||
private Boolean undefined;
|
||||
|
||||
public Info getInfo() {
|
||||
return this.info;
|
||||
}
|
||||
|
||||
public void setInfo(Info info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public Boolean getDefined() {
|
||||
return this.defined;
|
||||
}
|
||||
|
||||
public void setDefined(Boolean defined) {
|
||||
this.defined = defined;
|
||||
}
|
||||
|
||||
public Boolean getUndefined() {
|
||||
return this.undefined;
|
||||
}
|
||||
|
||||
public void setUndefined(Boolean undefined) {
|
||||
this.undefined = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Info {
|
||||
private Integer id;
|
||||
private Boolean enabled;
|
||||
|
||||
public Integer getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setID(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
test/jdk/java/beans/XMLEncoder/Test8027066.java
Normal file
42
test/jdk/java/beans/XMLEncoder/Test8027066.java
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 8027066
|
||||
* @summary Tests that the same array can be encoded twice
|
||||
* @run main/othervm Test8027066
|
||||
* @author Anton Nashatyrev
|
||||
*/
|
||||
public class Test8027066 extends AbstractTest<String[][]> {
|
||||
public static void main(String[] args) {
|
||||
new Test8027066().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[][] getObject() {
|
||||
String[] strings = {"first", "second"};
|
||||
String[][] arrays = {strings, strings};
|
||||
return arrays;
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/java_awt_AWTKeyStroke.java
Normal file
48
test/jdk/java/beans/XMLEncoder/java_awt_AWTKeyStroke.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6501431
|
||||
* @summary Tests AWTKeyStroke encoding
|
||||
* @run main/othervm java_awt_AWTKeyStroke
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.AWTKeyStroke;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
public final class java_awt_AWTKeyStroke extends AbstractTest<AWTKeyStroke> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_AWTKeyStroke().test();
|
||||
}
|
||||
|
||||
protected AWTKeyStroke getObject() {
|
||||
return AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_A, InputEvent.SHIFT_DOWN_MASK, true);
|
||||
}
|
||||
|
||||
protected AWTKeyStroke getAnotherObject() {
|
||||
return AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
}
|
||||
47
test/jdk/java/beans/XMLEncoder/java_awt_BasicStroke.java
Normal file
47
test/jdk/java/beans/XMLEncoder/java_awt_BasicStroke.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 4358979
|
||||
* @summary Tests BasicStroke encoding
|
||||
* @run main/othervm java_awt_BasicStroke
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
|
||||
public final class java_awt_BasicStroke extends AbstractTest<BasicStroke> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_BasicStroke().test();
|
||||
}
|
||||
|
||||
protected BasicStroke getObject() {
|
||||
return new BasicStroke();
|
||||
}
|
||||
|
||||
protected BasicStroke getAnotherObject() {
|
||||
float[] f = {1.0f, 2.0f, 3.0f, 4.0f};
|
||||
return new BasicStroke(f[1], BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, f[2], f, f[3]);
|
||||
}
|
||||
}
|
||||
81
test/jdk/java/beans/XMLEncoder/java_awt_BorderLayout.java
Normal file
81
test/jdk/java/beans/XMLEncoder/java_awt_BorderLayout.java
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2024, 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 4916852
|
||||
* @summary Tests BorderLayout encoding
|
||||
* @run main/othervm java_awt_BorderLayout
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public final class java_awt_BorderLayout extends AbstractTest<BorderLayout> {
|
||||
private static final String[] CONSTRAINTS = {
|
||||
BorderLayout.NORTH,
|
||||
BorderLayout.SOUTH,
|
||||
BorderLayout.EAST,
|
||||
BorderLayout.WEST,
|
||||
BorderLayout.CENTER,
|
||||
BorderLayout.PAGE_START,
|
||||
BorderLayout.PAGE_END,
|
||||
BorderLayout.LINE_START,
|
||||
BorderLayout.LINE_END,
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
new java_awt_BorderLayout().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BorderLayout getObject() {
|
||||
BorderLayout layout = new BorderLayout();
|
||||
update(layout, BorderLayout.EAST);
|
||||
update(layout, BorderLayout.WEST);
|
||||
update(layout, BorderLayout.NORTH);
|
||||
update(layout, BorderLayout.SOUTH);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BorderLayout getAnotherObject() {
|
||||
BorderLayout layout = getObject();
|
||||
update(layout, BorderLayout.CENTER);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate(BorderLayout before, BorderLayout after) {
|
||||
super.validate(before, after);
|
||||
for (String constraint : CONSTRAINTS) {
|
||||
super.validator.validate(before.getLayoutComponent(constraint),
|
||||
after.getLayoutComponent(constraint));
|
||||
}
|
||||
}
|
||||
|
||||
private static void update(BorderLayout layout, String constraints) {
|
||||
layout.addLayoutComponent(new JLabel(constraints), constraints);
|
||||
}
|
||||
}
|
||||
85
test/jdk/java/beans/XMLEncoder/java_awt_CardLayout.java
Normal file
85
test/jdk/java/beans/XMLEncoder/java_awt_CardLayout.java
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 8007458
|
||||
* @summary Tests CardLayout encoding
|
||||
* @modules java.desktop/java.awt:open
|
||||
* @run main/othervm java_awt_CardLayout
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Vector;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public final class java_awt_CardLayout extends AbstractTest<CardLayout> {
|
||||
private static final Field VECTOR = getField("java.awt.CardLayout.vector");
|
||||
private static final Field NAME = getField("java.awt.CardLayout$Card.name");
|
||||
private static final Field COMP = getField("java.awt.CardLayout$Card.comp");
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new java_awt_CardLayout().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CardLayout getObject() {
|
||||
CardLayout layout = new CardLayout();
|
||||
layout.addLayoutComponent(new JLabel("a"), "a");
|
||||
layout.addLayoutComponent(new JLabel("b"), "b");
|
||||
layout.addLayoutComponent(new JLabel("c"), "c");
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CardLayout getAnotherObject() {
|
||||
CardLayout layout = new CardLayout();
|
||||
layout.addLayoutComponent(new JLabel("a"), "a");
|
||||
layout.addLayoutComponent(new JLabel("b"), "b");
|
||||
layout.addLayoutComponent(new JLabel("c"), "c");
|
||||
layout.addLayoutComponent(new JLabel("d"), "d");
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate(CardLayout before, CardLayout after) {
|
||||
super.validate(before, after);
|
||||
try {
|
||||
Vector a = (Vector) VECTOR.get(after);
|
||||
Vector b = (Vector) VECTOR.get(before);
|
||||
int size = a.size();
|
||||
if (size != b.size()) {
|
||||
throw new Error("different content");
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
super.validator.validate(NAME.get(a.get(i)), NAME.get(b.get(i)));
|
||||
super.validator.validate(COMP.get(a.get(i)), COMP.get(b.get(i)));
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new Error(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
test/jdk/java/beans/XMLEncoder/java_awt_Color.java
Normal file
46
test/jdk/java/beans/XMLEncoder/java_awt_Color.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062 6487891
|
||||
* @summary Tests Color encoding
|
||||
* @run main/othervm java_awt_Color
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public final class java_awt_Color extends AbstractTest<Color> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Color().test();
|
||||
}
|
||||
|
||||
protected Color getObject() {
|
||||
return new Color(0x88, 0x44, 0x22, 0x11);
|
||||
}
|
||||
|
||||
protected Color getAnotherObject() {
|
||||
return Color.BLACK;
|
||||
}
|
||||
}
|
||||
60
test/jdk/java/beans/XMLEncoder/java_awt_Component.java
Normal file
60
test/jdk/java/beans/XMLEncoder/java_awt_Component.java
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2024, 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 4916852
|
||||
* @summary Tests Component encoding (background, foreground and font)
|
||||
* @run main/othervm java_awt_Component
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
|
||||
public final class java_awt_Component extends AbstractTest<Component> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Component().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getObject() {
|
||||
Component component = new MyComponent();
|
||||
component.setBackground(Color.WHITE);
|
||||
component.setFont(new Font(null, Font.BOLD, 5));
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Component getAnotherObject() {
|
||||
Component component = new MyComponent();
|
||||
component.setForeground(Color.BLACK);
|
||||
component.setFont(new Font(null, Font.ITALIC, 6));
|
||||
return component;
|
||||
}
|
||||
|
||||
public static final class MyComponent extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
47
test/jdk/java/beans/XMLEncoder/java_awt_Cursor.java
Normal file
47
test/jdk/java/beans/XMLEncoder/java_awt_Cursor.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062 6487891
|
||||
* @summary Tests Cursor encoding
|
||||
* @run main/othervm java_awt_Cursor
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Cursor;
|
||||
|
||||
public final class java_awt_Cursor extends AbstractTest<Cursor> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Cursor().test();
|
||||
}
|
||||
|
||||
protected Cursor getObject() {
|
||||
return new Cursor(Cursor.MOVE_CURSOR);
|
||||
}
|
||||
|
||||
protected Cursor getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return Cursor.getDefaultCursor();
|
||||
}
|
||||
}
|
||||
46
test/jdk/java/beans/XMLEncoder/java_awt_Dimension.java
Normal file
46
test/jdk/java/beans/XMLEncoder/java_awt_Dimension.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4741757 6402062 6471539
|
||||
* @summary Tests Dimension encoding
|
||||
* @run main/othervm java_awt_Dimension
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
public final class java_awt_Dimension extends AbstractTest<Dimension> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Dimension().test();
|
||||
}
|
||||
|
||||
protected Dimension getObject() {
|
||||
return new Dimension();
|
||||
}
|
||||
|
||||
protected Dimension getAnotherObject() {
|
||||
return new Dimension(-5, 5);
|
||||
}
|
||||
}
|
||||
51
test/jdk/java/beans/XMLEncoder/java_awt_Font.java
Normal file
51
test/jdk/java/beans/XMLEncoder/java_awt_Font.java
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4951733 6402062
|
||||
* @summary Tests Font encoding
|
||||
* @run main/othervm java_awt_Font
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class java_awt_Font extends AbstractTest<Font> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Font().test();
|
||||
}
|
||||
|
||||
protected Font getObject() {
|
||||
Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object>();
|
||||
map.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
|
||||
return new Font(map);
|
||||
}
|
||||
|
||||
protected Font getAnotherObject() {
|
||||
return new Font("SansSerif", Font.BOLD, 10).deriveFont(12.12f);
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/java_awt_GradientPaint.java
Normal file
48
test/jdk/java/beans/XMLEncoder/java_awt_GradientPaint.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 4358979
|
||||
* @summary Tests GradientPaint encoding
|
||||
* @run main/othervm java_awt_GradientPaint
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
|
||||
public final class java_awt_GradientPaint extends AbstractTest<GradientPaint> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_GradientPaint().test();
|
||||
}
|
||||
|
||||
protected GradientPaint getObject() {
|
||||
return new GradientPaint(0.1f, 0.2f, Color.BLACK, 0.3f, 0.4f, Color.WHITE, true);
|
||||
}
|
||||
|
||||
protected GradientPaint getAnotherObject() {
|
||||
return null; /* TODO: could not update property
|
||||
return new GradientPaint(0.4f, 0.3f, Color.WHITE, 0.2f, 0.1f, Color.BLACK, false);*/
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062
|
||||
* @summary Tests GridBagConstraints encoding
|
||||
* @run main/othervm java_awt_GridBagConstraints
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
|
||||
public final class java_awt_GridBagConstraints extends AbstractTest<GridBagConstraints> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_GridBagConstraints().test();
|
||||
}
|
||||
|
||||
protected GridBagConstraints getObject() {
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 2;
|
||||
gbc.gridwidth = 3;
|
||||
gbc.gridheight = 4;
|
||||
gbc.weightx = 0.1;
|
||||
gbc.weighty = 0.2;
|
||||
gbc.anchor = GridBagConstraints.NORTH;
|
||||
gbc.fill = GridBagConstraints.VERTICAL;
|
||||
gbc.insets.top = 1;
|
||||
gbc.insets.left = 2;
|
||||
gbc.insets.right = 3;
|
||||
gbc.insets.bottom = 4;
|
||||
gbc.ipadx = -1;
|
||||
gbc.ipady = -2;
|
||||
return gbc;
|
||||
}
|
||||
|
||||
protected GridBagConstraints getAnotherObject() {
|
||||
return new GridBagConstraints();
|
||||
}
|
||||
}
|
||||
101
test/jdk/java/beans/XMLEncoder/java_awt_GridBagLayout.java
Normal file
101
test/jdk/java/beans/XMLEncoder/java_awt_GridBagLayout.java
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, 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 8007458
|
||||
* @summary Tests GridBagLayout encoding
|
||||
* @modules java.desktop/java.awt:open
|
||||
* @run main/othervm java_awt_GridBagLayout
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Hashtable;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public final class java_awt_GridBagLayout extends AbstractTest<GridBagLayout> {
|
||||
private static final Field HASHTABLE = getField("java.awt.GridBagLayout.comptable");
|
||||
|
||||
public static void main(String[] args) {
|
||||
new java_awt_GridBagLayout().test();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GridBagLayout getObject() {
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
update(layout, "1", 1, 1);
|
||||
update(layout, "2", 2, 2);
|
||||
update(layout, "3", 3, 3);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GridBagLayout getAnotherObject() {
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
update(layout, "11", 1, 1);
|
||||
update(layout, "12", 1, 2);
|
||||
update(layout, "21", 2, 1);
|
||||
update(layout, "22", 2, 2);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate(GridBagLayout before, GridBagLayout after) {
|
||||
super.validate(before, after);
|
||||
try {
|
||||
Hashtable a = (Hashtable) HASHTABLE.get(after);
|
||||
Hashtable b = (Hashtable) HASHTABLE.get(before);
|
||||
super.validator.validate(a, b);
|
||||
|
||||
// for (int i = 0; i < size; i++) {
|
||||
// validator.validate(NAME.get(a.get(i)), NAME.get(b.get(i)));
|
||||
// validator.validate(COMP.get(a.get(i)), COMP.get(b.get(i)));
|
||||
// }
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new Error(exception);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// for (String name : names) {
|
||||
// validator.validate(getConstraints(before, name), getConstraints(after, name));
|
||||
// }
|
||||
}
|
||||
|
||||
private static void update(GridBagLayout layout, String id, int x, int y) {
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridx = x;
|
||||
gbc.gridy = y;
|
||||
layout.addLayoutComponent(new JLabel(id), gbc);
|
||||
}
|
||||
|
||||
/*
|
||||
private static GridBagConstraints getConstraints(GridBagLayout layout, String id) {
|
||||
return (layout == null) ? null : ((MyGridBagLayout) layout).getConstraints(id);
|
||||
}
|
||||
*/
|
||||
}
|
||||
46
test/jdk/java/beans/XMLEncoder/java_awt_Insets.java
Normal file
46
test/jdk/java/beans/XMLEncoder/java_awt_Insets.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062 6471539
|
||||
* @summary Tests Insets encoding
|
||||
* @run main/othervm java_awt_Insets
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Insets;
|
||||
|
||||
public final class java_awt_Insets extends AbstractTest<Insets> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Insets().test();
|
||||
}
|
||||
|
||||
protected Insets getObject() {
|
||||
return new Insets(1, 2, 3, 4);
|
||||
}
|
||||
|
||||
protected Insets getAnotherObject() {
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 4358979
|
||||
* @summary Tests LinearGradientPaint encoding
|
||||
* @run main/othervm java_awt_LinearGradientPaint
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.LinearGradientPaint;
|
||||
|
||||
public final class java_awt_LinearGradientPaint extends AbstractTest<LinearGradientPaint> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_LinearGradientPaint().test();
|
||||
}
|
||||
|
||||
protected LinearGradientPaint getObject() {
|
||||
float[] f = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f };
|
||||
Color[] c = { Color.BLUE, Color.GREEN, Color.RED, Color.BLUE, Color.GREEN, Color.RED };
|
||||
return new LinearGradientPaint(f[0], f[1], f[2], f[3], f, c);
|
||||
}
|
||||
|
||||
protected LinearGradientPaint getAnotherObject() {
|
||||
return null; /* TODO: could not update property
|
||||
float[] f = { 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f };
|
||||
Color[] c = { Color.RED, Color.GREEN, Color.BLUE, Color.RED, Color.GREEN, Color.BLUE };
|
||||
return new LinearGradientPaint(
|
||||
new Point2D.Float(f[0], f[1]),
|
||||
new Point2D.Float(f[2], f[3]),
|
||||
f, c, REFLECT, LINEAR_RGB,
|
||||
new AffineTransform(f));*/
|
||||
}
|
||||
}
|
||||
47
test/jdk/java/beans/XMLEncoder/java_awt_MenuShortcut.java
Normal file
47
test/jdk/java/beans/XMLEncoder/java_awt_MenuShortcut.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 4818598
|
||||
* @summary Tests MenuShortcut value encoding
|
||||
* @run main/othervm java_awt_MenuShortcut
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.MenuShortcut;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public final class java_awt_MenuShortcut extends AbstractTest<MenuShortcut> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_MenuShortcut().test();
|
||||
}
|
||||
|
||||
protected MenuShortcut getObject() {
|
||||
return new MenuShortcut(KeyEvent.VK_A);
|
||||
}
|
||||
|
||||
protected MenuShortcut getAnotherObject() {
|
||||
return new MenuShortcut(KeyEvent.VK_Z, true);
|
||||
}
|
||||
}
|
||||
46
test/jdk/java/beans/XMLEncoder/java_awt_Point.java
Normal file
46
test/jdk/java/beans/XMLEncoder/java_awt_Point.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4741757 6402062 6471539
|
||||
* @summary Tests Point encoding
|
||||
* @run main/othervm java_awt_Point
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
public final class java_awt_Point extends AbstractTest<Point> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Point().test();
|
||||
}
|
||||
|
||||
protected Point getObject() {
|
||||
return new Point(-5, 5);
|
||||
}
|
||||
|
||||
protected Point getAnotherObject() {
|
||||
return new Point();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 4358979
|
||||
* @summary Tests RadialGradientPaint encoding
|
||||
* @run main/othervm java_awt_RadialGradientPaint
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.RadialGradientPaint;
|
||||
|
||||
public final class java_awt_RadialGradientPaint extends AbstractTest<RadialGradientPaint> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_RadialGradientPaint().test();
|
||||
}
|
||||
|
||||
protected RadialGradientPaint getObject() {
|
||||
float[] f = { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f };
|
||||
Color[] c = { Color.BLUE, Color.GREEN, Color.RED, Color.BLUE, Color.GREEN, Color.RED };
|
||||
return new RadialGradientPaint(f[0], f[1], f[2], f, c);
|
||||
}
|
||||
|
||||
protected RadialGradientPaint getAnotherObject() {
|
||||
return null; /* TODO: could not update property
|
||||
float[] f = { 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f };
|
||||
Color[] c = { Color.RED, Color.GREEN, Color.BLUE, Color.RED, Color.GREEN, Color.BLUE };
|
||||
return new RadialGradientPaint(
|
||||
new Point2D.Float(f[0], f[1]), 100.0f,
|
||||
new Point2D.Float(f[2], f[3]),
|
||||
f, c, REFLECT, LINEAR_RGB,
|
||||
new AffineTransform(f));*/
|
||||
}
|
||||
}
|
||||
46
test/jdk/java/beans/XMLEncoder/java_awt_Rectangle.java
Normal file
46
test/jdk/java/beans/XMLEncoder/java_awt_Rectangle.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4741757 6402062 6471539
|
||||
* @summary Tests Rectangle encoding
|
||||
* @run main/othervm java_awt_Rectangle
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
public final class java_awt_Rectangle extends AbstractTest<Rectangle> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_Rectangle().test();
|
||||
}
|
||||
|
||||
protected Rectangle getObject() {
|
||||
return new Rectangle(1, 2, 3, 4);
|
||||
}
|
||||
|
||||
protected Rectangle getAnotherObject() {
|
||||
return new Rectangle();
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/java_awt_ScrollPane.java
Normal file
48
test/jdk/java/beans/XMLEncoder/java_awt_ScrollPane.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062 6487891
|
||||
* @summary Tests ScrollPane encoding
|
||||
* @key headful
|
||||
* @run main/othervm java_awt_ScrollPane
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.ScrollPane;
|
||||
|
||||
public final class java_awt_ScrollPane extends AbstractTest<ScrollPane> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_ScrollPane().test();
|
||||
}
|
||||
|
||||
protected ScrollPane getObject() {
|
||||
return new ScrollPane(ScrollPane.SCROLLBARS_NEVER);
|
||||
}
|
||||
|
||||
protected ScrollPane getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2024, 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 4358979
|
||||
* @summary Tests AffineTransform encoding
|
||||
* @run main/othervm java_awt_geom_AffineTransform
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
public final class java_awt_geom_AffineTransform extends AbstractTest<AffineTransform> {
|
||||
public static void main(String[] args) {
|
||||
new java_awt_geom_AffineTransform().test();
|
||||
}
|
||||
|
||||
protected AffineTransform getObject() {
|
||||
return new AffineTransform(0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f);
|
||||
}
|
||||
|
||||
protected AffineTransform getAnotherObject() {
|
||||
return new AffineTransform(0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f);
|
||||
}
|
||||
}
|
||||
47
test/jdk/java/beans/XMLEncoder/java_beans_EventHandler.java
Normal file
47
test/jdk/java/beans/XMLEncoder/java_beans_EventHandler.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062 6487891
|
||||
* @summary Tests EventHandler encoding
|
||||
* @run main/othervm java_beans_EventHandler
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.EventHandler;
|
||||
|
||||
public final class java_beans_EventHandler extends AbstractTest<EventHandler> {
|
||||
public static void main(String[] args) {
|
||||
new java_beans_EventHandler().test();
|
||||
}
|
||||
|
||||
protected EventHandler getObject() {
|
||||
return new EventHandler("target", "action", "property", "listener");
|
||||
}
|
||||
|
||||
protected EventHandler getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return new EventHandler("target", "action", null, null);
|
||||
}
|
||||
}
|
||||
47
test/jdk/java/beans/XMLEncoder/java_beans_Expression.java
Normal file
47
test/jdk/java/beans/XMLEncoder/java_beans_Expression.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062 6487891
|
||||
* @summary Tests Expression encoding
|
||||
* @run main/othervm java_beans_Expression
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Expression;
|
||||
|
||||
public final class java_beans_Expression extends AbstractTest<Expression> {
|
||||
public static void main(String[] args) {
|
||||
new java_beans_Expression().test();
|
||||
}
|
||||
|
||||
protected Expression getObject() {
|
||||
return new Expression("target", "equals", new String[] {"argument"});
|
||||
}
|
||||
|
||||
protected Expression getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return new Expression("target", "equals", null);
|
||||
}
|
||||
}
|
||||
47
test/jdk/java/beans/XMLEncoder/java_beans_Statement.java
Normal file
47
test/jdk/java/beans/XMLEncoder/java_beans_Statement.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6402062 6487891
|
||||
* @summary Tests Statement encoding
|
||||
* @run main/othervm java_beans_Statement
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Statement;
|
||||
|
||||
public final class java_beans_Statement extends AbstractTest<Statement> {
|
||||
public static void main(String[] args) {
|
||||
new java_beans_Statement().test();
|
||||
}
|
||||
|
||||
protected Statement getObject() {
|
||||
return new Statement("target", "method", new String[] {"arg1", "arg2"});
|
||||
}
|
||||
|
||||
protected Statement getAnotherObject() {
|
||||
return null; // TODO: could not update property
|
||||
// return new Statement("target", "method", null);
|
||||
}
|
||||
}
|
||||
44
test/jdk/java/beans/XMLEncoder/java_lang_Character.java
Normal file
44
test/jdk/java/beans/XMLEncoder/java_lang_Character.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6256805
|
||||
* @summary Tests invalid XML character encoding
|
||||
* @run main/othervm java_lang_Character
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class java_lang_Character extends AbstractTest<Character> {
|
||||
public static void main(String[] args) {
|
||||
new java_lang_Character().test();
|
||||
}
|
||||
|
||||
protected Character getObject() {
|
||||
return Character.valueOf('\\');
|
||||
}
|
||||
|
||||
protected Character getAnotherObject() {
|
||||
return Character.valueOf('\uFFFF');
|
||||
}
|
||||
}
|
||||
44
test/jdk/java/beans/XMLEncoder/java_lang_Class.java
Normal file
44
test/jdk/java/beans/XMLEncoder/java_lang_Class.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 4818598
|
||||
* @summary Tests Class value encoding
|
||||
* @run main/othervm java_lang_Class
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class java_lang_Class extends AbstractTest<Class> {
|
||||
public static void main(String[] args) {
|
||||
new java_lang_Class().test();
|
||||
}
|
||||
|
||||
protected Class getObject() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
protected Class getAnotherObject() {
|
||||
return Number.class;
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/java_lang_Enum.java
Normal file
48
test/jdk/java/beans/XMLEncoder/java_lang_Enum.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 5015403
|
||||
* @summary Tests Enum value encoding
|
||||
* @run main/othervm java_lang_Enum
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class java_lang_Enum extends AbstractTest {
|
||||
public static void main(String[] args) {
|
||||
new java_lang_Enum().test();
|
||||
}
|
||||
|
||||
protected Object getObject() {
|
||||
return Alpha.A;
|
||||
}
|
||||
|
||||
protected Object getAnotherObject() {
|
||||
return Alpha.Z;
|
||||
}
|
||||
|
||||
public enum Alpha {
|
||||
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
|
||||
}
|
||||
}
|
||||
49
test/jdk/java/beans/XMLEncoder/java_lang_String.java
Normal file
49
test/jdk/java/beans/XMLEncoder/java_lang_String.java
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6256805
|
||||
* @summary Tests invalid XML string encoding
|
||||
* @run main/othervm java_lang_String
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
public final class java_lang_String extends AbstractTest<String> {
|
||||
public static void main(String[] args) {
|
||||
new java_lang_String().test();
|
||||
}
|
||||
|
||||
protected String getObject() {
|
||||
return "\u0000\ud800\udc00\uFFFF";
|
||||
}
|
||||
|
||||
protected String getAnotherObject() {
|
||||
int length = 0x10000;
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
while (0 < length--) {
|
||||
sb.append((char) length);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
57
test/jdk/java/beans/XMLEncoder/java_lang_reflect_Field.java
Normal file
57
test/jdk/java/beans/XMLEncoder/java_lang_reflect_Field.java
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 4818598
|
||||
* @summary Tests Field value encoding
|
||||
* @run main/othervm java_lang_reflect_Field
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public final class java_lang_reflect_Field extends AbstractTest<Field> {
|
||||
public int f1;
|
||||
public int f2;
|
||||
|
||||
public static void main(String[] args) {
|
||||
new java_lang_reflect_Field().test();
|
||||
}
|
||||
|
||||
protected Field getObject() {
|
||||
try {
|
||||
return java_lang_reflect_Field.class.getField("f1");
|
||||
} catch (NoSuchFieldException exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
}
|
||||
|
||||
protected Field getAnotherObject() {
|
||||
try {
|
||||
return java_lang_reflect_Field.class.getField("f2");
|
||||
} catch (NoSuchFieldException exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
test/jdk/java/beans/XMLEncoder/java_lang_reflect_Method.java
Normal file
60
test/jdk/java/beans/XMLEncoder/java_lang_reflect_Method.java
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 4818598
|
||||
* @summary Tests Method value encoding
|
||||
* @run main/othervm java_lang_reflect_Method
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class java_lang_reflect_Method extends AbstractTest<Method> {
|
||||
public static void main(String[] args) {
|
||||
new java_lang_reflect_Method().test();
|
||||
}
|
||||
|
||||
protected Method getObject() {
|
||||
try {
|
||||
return java_lang_reflect_Method.class.getMethod("m1");
|
||||
} catch (NoSuchMethodException exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
}
|
||||
|
||||
protected Method getAnotherObject() {
|
||||
try {
|
||||
return java_lang_reflect_Method.class.getMethod("m2");
|
||||
} catch (NoSuchMethodException exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void m1() {
|
||||
}
|
||||
|
||||
public void m2() {
|
||||
}
|
||||
}
|
||||
55
test/jdk/java/beans/XMLEncoder/java_net_URI.java
Normal file
55
test/jdk/java/beans/XMLEncoder/java_net_URI.java
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 6245149
|
||||
* @summary Tests URI encoding
|
||||
* @run main/othervm java_net_URI
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public final class java_net_URI extends AbstractTest<URI> {
|
||||
public static void main(String[] args) {
|
||||
new java_net_URI().test();
|
||||
}
|
||||
|
||||
protected URI getObject() {
|
||||
try {
|
||||
return new URI("http://www.sun.com/");
|
||||
} catch (URISyntaxException exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
}
|
||||
|
||||
protected URI getAnotherObject() {
|
||||
try {
|
||||
return new URI("ftp://www.sun.com/");
|
||||
} catch (URISyntaxException exception) {
|
||||
throw new Error("unexpected exception", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/java_sql_Date.java
Normal file
48
test/jdk/java/beans/XMLEncoder/java_sql_Date.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4733558 6471539
|
||||
* @summary Tests Date encoding
|
||||
* @run main/othervm java_sql_Date
|
||||
* @author Sergey Malenkov
|
||||
* @modules java.desktop
|
||||
* java.sql
|
||||
*/
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
public final class java_sql_Date extends AbstractTest<Date> {
|
||||
public static void main(String[] args) {
|
||||
new java_sql_Date().test();
|
||||
}
|
||||
|
||||
protected Date getObject() {
|
||||
return new Date(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
protected Date getAnotherObject() {
|
||||
return new Date(0L);
|
||||
}
|
||||
}
|
||||
48
test/jdk/java/beans/XMLEncoder/java_sql_Time.java
Normal file
48
test/jdk/java/beans/XMLEncoder/java_sql_Time.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4733558 6471539
|
||||
* @summary Tests Time encoding
|
||||
* @run main/othervm java_sql_Time
|
||||
* @author Sergey Malenkov
|
||||
* @modules java.desktop
|
||||
* java.sql
|
||||
*/
|
||||
|
||||
import java.sql.Time;
|
||||
|
||||
public final class java_sql_Time extends AbstractTest<Time> {
|
||||
public static void main(String[] args) {
|
||||
new java_sql_Time().test();
|
||||
}
|
||||
|
||||
protected Time getObject() {
|
||||
return new Time(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
protected Time getAnotherObject() {
|
||||
return new Time(0L);
|
||||
}
|
||||
}
|
||||
50
test/jdk/java/beans/XMLEncoder/java_sql_Timestamp.java
Normal file
50
test/jdk/java/beans/XMLEncoder/java_sql_Timestamp.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2024, 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 4733558 6471539
|
||||
* @summary Tests Timestamp encoding
|
||||
* @run main/othervm java_sql_Timestamp
|
||||
* @author Sergey Malenkov
|
||||
* @modules java.desktop
|
||||
* java.sql
|
||||
*/
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public final class java_sql_Timestamp extends AbstractTest<Timestamp> {
|
||||
public static void main(String[] args) {
|
||||
new java_sql_Timestamp().test();
|
||||
}
|
||||
|
||||
protected Timestamp getObject() {
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
timestamp.setNanos(1 + timestamp.getNanos());
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
protected Timestamp getAnotherObject() {
|
||||
return new Timestamp(0L);
|
||||
}
|
||||
}
|
||||
50
test/jdk/java/beans/XMLEncoder/java_util_ArrayList.java
Normal file
50
test/jdk/java/beans/XMLEncoder/java_util_ArrayList.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 4631471
|
||||
* @summary Tests ArrayList encoding
|
||||
* @run main/othervm java_util_ArrayList
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class java_util_ArrayList extends AbstractTest<List<String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_ArrayList().test();
|
||||
}
|
||||
|
||||
protected List<String> getObject() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(null);
|
||||
list.add("string");
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<String> getAnotherObject() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests EmptyList encoding
|
||||
* @run main/othervm java_util_Collections_EmptyList
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class java_util_Collections_EmptyList extends AbstractTest<List<String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_Collections_EmptyList().test();
|
||||
}
|
||||
|
||||
protected List<String> getObject() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected List<String> getAnotherObject() {
|
||||
return Collections.singletonList("string");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests EmptyMap encoding
|
||||
* @run main/othervm java_util_Collections_EmptyMap
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public final class java_util_Collections_EmptyMap extends AbstractTest<Map<String, String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_Collections_EmptyMap().test();
|
||||
}
|
||||
|
||||
protected Map<String, String> getObject() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
protected Map<String, String> getAnotherObject() {
|
||||
return Collections.singletonMap("key", "value");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests EmptySet encoding
|
||||
* @run main/othervm java_util_Collections_EmptySet
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public final class java_util_Collections_EmptySet extends AbstractTest<Set<String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_Collections_EmptySet().test();
|
||||
}
|
||||
|
||||
protected Set<String> getObject() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
protected Set<String> getAnotherObject() {
|
||||
return Collections.singleton("string");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests SingletonList encoding
|
||||
* @run main/othervm java_util_Collections_SingletonList
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class java_util_Collections_SingletonList extends AbstractTest<List<String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_Collections_SingletonList().test();
|
||||
}
|
||||
|
||||
protected List<String> getObject() {
|
||||
return Collections.singletonList("string");
|
||||
}
|
||||
|
||||
protected List<String> getAnotherObject() {
|
||||
return Collections.singletonList("object");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests SingletonMap encoding
|
||||
* @run main/othervm java_util_Collections_SingletonMap
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public final class java_util_Collections_SingletonMap extends AbstractTest<Map<String, String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_Collections_SingletonMap().test();
|
||||
}
|
||||
|
||||
protected Map<String, String> getObject() {
|
||||
return Collections.singletonMap("key", "value");
|
||||
}
|
||||
|
||||
protected Map<String, String> getAnotherObject() {
|
||||
return Collections.singletonMap("value", "key");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests SingletonSet encoding
|
||||
* @run main/othervm java_util_Collections_SingletonSet
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public final class java_util_Collections_SingletonSet extends AbstractTest<Set<String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_Collections_SingletonSet().test();
|
||||
}
|
||||
|
||||
protected Set<String> getObject() {
|
||||
return Collections.singleton("string");
|
||||
}
|
||||
|
||||
protected Set<String> getAnotherObject() {
|
||||
return Collections.singleton("object");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2024, 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 6505888
|
||||
* @summary Tests SynchronizedCollection encoding
|
||||
* @run main/othervm java_util_Collections_SynchronizedCollection
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class java_util_Collections_SynchronizedCollection extends AbstractTest<Collection<String>> {
|
||||
public static void main(String[] args) {
|
||||
new java_util_Collections_SynchronizedCollection().test();
|
||||
}
|
||||
|
||||
protected Collection<String> getObject() {
|
||||
List<String> list = Collections.singletonList("string");
|
||||
return Collections.synchronizedCollection(list);
|
||||
}
|
||||
|
||||
protected Collection<String> getAnotherObject() {
|
||||
List<String> list = Collections.emptyList();
|
||||
return Collections.synchronizedCollection(list);
|
||||
}
|
||||
}
|
||||
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