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:
russell@unturf.com 2026-03-26 17:11:57 -04:00
commit 0a580b313d
70422 changed files with 17213626 additions and 0 deletions

View file

@ -0,0 +1,106 @@
/*
* Copyright (c) 2014, 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 8067422
* @summary Check that the lambda names are not unnecessarily unstable
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap
* @build toolbox.ToolBox toolbox.JavacTask
* @run main TestNonSerializableLambdaNameStability
*/
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.tools.StandardLocation;
import java.lang.classfile.*;
import toolbox.JavacTask;
import toolbox.ToolBox;
public class TestNonSerializableLambdaNameStability {
public static void main(String... args) throws Exception {
new TestNonSerializableLambdaNameStability().run();
}
String lambdaSource = "public class L%d {\n" +
" public static class A {\n" +
" private Runnable r = () -> { };\n" +
" }\n" +
" public static class B {\n" +
" private Runnable r = () -> { };\n" +
" }\n" +
" private Runnable r = () -> { };\n" +
"}\n";
String expectedLambdaMethodName = "lambda$new$0";
void run() throws Exception {
List<String> sources = new ArrayList<>();
for (int i = 0; i < 3; i++) {
sources.add(String.format(lambdaSource, i));
}
ToolBox tb = new ToolBox();
try (ToolBox.MemoryFileManager fm = new ToolBox.MemoryFileManager()) {
new JavacTask(tb)
.sources(sources.toArray(new String[sources.size()]))
.fileManager(fm)
.run();
for (String file : fm.getFileNames(StandardLocation.CLASS_OUTPUT)) {
byte[] fileBytes = fm.getFileBytes(StandardLocation.CLASS_OUTPUT, file);
try (InputStream in = new ByteArrayInputStream(fileBytes)) {
boolean foundLambdaMethod = false;
ClassModel cf = ClassFile.of().parse(in.readAllBytes());
StringBuilder seenMethods = new StringBuilder();
String sep = "";
for (MethodModel m : cf.methods()) {
String methodName = m.methodName().stringValue();
if (expectedLambdaMethodName.equals(methodName)) {
foundLambdaMethod = true;
break;
}
seenMethods.append(sep);
seenMethods.append(methodName);
sep = ", ";
}
if (!foundLambdaMethod) {
throw new AbstractMethodError("Did not find the lambda method, " +
"found methods: " + seenMethods.toString());
}
}
}
}
}
}

View file

@ -0,0 +1,173 @@
/*
* Copyright (c) 2013, 2016, 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 8023668
* @summary Desugar serializable lambda bodies using more robust naming scheme
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap
* @build toolbox.ToolBox toolbox.JavacTask
* @run main TestSerializedLambdaNameStability
*/
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.*;
import toolbox.JavacTask;
import toolbox.ToolBox;
public class TestSerializedLambdaNameStability {
final ClassLoader writingClassLoader;
final ClassLoader clonedClassLoader;
final ClassLoader checkingClassLoader;
TestSerializedLambdaNameStability() {
writingClassLoader = new TestClassLoader("before");
clonedClassLoader = new TestClassLoader("before");
checkingClassLoader = new TestClassLoader("after");
}
public static void main(String... args) throws Exception {
new TestSerializedLambdaNameStability().doit("NameOfCapturedArgs", true);
new TestSerializedLambdaNameStability().doit("TypesOfCapturedArgs", true);
new TestSerializedLambdaNameStability().doit("OrderOfCapturedArgs", true);
new TestSerializedLambdaNameStability().doit("VariableAssignmentTarget", false);
new TestSerializedLambdaNameStability().doit("TargetName", true);
new TestSerializedLambdaNameStability().doit("TargetType", true);
}
public void doit(String name, boolean expectFail) throws Exception {
String iName = "I" + name;
String testName = "TEST" + name;
Class<?> kw = writingClassLoader.loadClass(testName);
Object instw = getInstance(kw);
Method mw = getMethod(kw, "write", ObjectOutput.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ObjectOutput out = new ObjectOutputStream(baos)) {
mw.invoke(instw, out);
}
byte[] ser = baos.toByteArray();
// Read and check clone
readCheck(iName, testName, clonedClassLoader, ser);
System.err.printf("cloned test readCheck %s\n", testName);
// Read and check other
if (expectFail) {
try {
readCheck(iName, testName, checkingClassLoader, ser);
} catch (InvocationTargetException ite) {
Throwable underlying = ite;
while (underlying != null && !(underlying instanceof IllegalArgumentException)) {
underlying = underlying.getCause();
}
if (underlying != null) {
if (underlying.getMessage().contains("deserialization")) {
System.err.printf("PASS: other test %s got expected exception %s\n", testName, underlying);
return;
}
}
System.err.printf("FAIL: other test %s got unexpected exception %s\n", testName, ite);
throw new Exception("unexpected exception ", ite);
}
System.err.printf("FAIL: other test %s expected an exception", testName);
throw new Exception("expected an exception" + testName);
} else {
readCheck(iName, testName, checkingClassLoader, ser);
System.err.printf("PASS: other test %s readCheck\n", testName);
}
}
void readCheck(String iName, String testName, ClassLoader loader, byte[] ser) throws Exception {
Class<?> k = loader.loadClass(testName);
Object inst = getInstance(k);
Method mrc = getMethod(k, "readCheck", ObjectInput.class);
ByteArrayInputStream bais = new ByteArrayInputStream(ser);
try (ObjectInput in = new ObjectInputStream(bais)) {
mrc.invoke(inst, in);
}
}
Method getMethod(Class<?> k, String name, Class<?> argTypes) throws Exception {
Method meth = k.getDeclaredMethod(name, argTypes);
meth.setAccessible(true);
return meth;
}
Object getInstance(Class<?> k) throws Exception {
Constructor<?> cons = k.getConstructors()[0];
cons.setAccessible(true);
return cons.newInstance();
}
static class TestClassLoader extends ClassLoader {
static final String compiledDir = System.getProperty("user.dir");
static final String sourceBaseDir = System.getProperty("test.src");
final ToolBox tb = new ToolBox();
final String context;
public TestClassLoader(String context) {
super();
this.context = context;
}
@Override
public Class findClass(String name) throws ClassNotFoundException {
byte[] b;
try {
b = loadClassData(name);
} catch (Throwable th) {
// th.printStackTrace();
throw new ClassNotFoundException("Loading error", th);
}
return defineClass(name, b, 0, b.length);
}
private byte[] loadClassData(String name) throws Exception {
String srcName;
if (name.startsWith("TEST"))
srcName = name;
else if (name.startsWith("I"))
srcName = "TEST" + name.substring(1);
else
throw new Exception("Did not expect to load " + name);
Path srcFile = Paths.get(sourceBaseDir, context, srcName + ".java");
new JavacTask(tb)
.outdir(compiledDir)
.files(srcFile)
.run();
Path cfFile = Paths.get(compiledDir, name + ".class");
byte[] bytes = Files.readAllBytes(cfFile);
return bytes;
}
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface INameOfCapturedArgs extends Serializable {
int get();
}
class TESTNameOfCapturedArgs {
public TESTNameOfCapturedArgs() {
}
public void write(ObjectOutput out) throws IOException {
int y = 44;
INameOfCapturedArgs res = () -> y;
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
INameOfCapturedArgs lam = (INameOfCapturedArgs) in.readObject();
int val = lam.get();
if (val != 44) {
throw new IllegalArgumentException("Expected 44");
}
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface IOrderOfCapturedArgs extends Serializable {
String get();
}
class TESTOrderOfCapturedArgs {
public TESTOrderOfCapturedArgs() {
}
public void write(ObjectOutput out) throws IOException {
String a = "fu";
String b = "bar";
IOrderOfCapturedArgs res = () -> b + a;
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
IOrderOfCapturedArgs lam = (IOrderOfCapturedArgs) in.readObject();
Object val = lam.get();
if (!val.equals("fubar")) {
throw new IllegalArgumentException("Expected 'fubar'");
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface ITargetName extends Serializable {
String get();
}
class TESTTargetName {
public TESTTargetName() {
}
public void write(ObjectOutput out) throws IOException {
ITargetName resist = () -> "fubar";
out.writeObject(resist);
}
public void readCheck(ObjectInput in) throws Exception {
ITargetName lam = (ITargetName) in.readObject();
Object val = lam.get();
if (!val.equals("fubar")) {
throw new IllegalArgumentException("Expected 'fubar'");
}
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
import java.util.function.*;
class TESTTargetType {
public TESTTargetType() {
}
public void write(ObjectOutput out) throws IOException {
Object res = (Predicate<String> & Serializable) ((str) -> str.length() > 3);
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
in.readObject();
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface ITypesOfCapturedArgs extends Serializable {
Object get();
}
class TESTTypesOfCapturedArgs {
public TESTTypesOfCapturedArgs() {
}
public void write(ObjectOutput out) throws IOException {
Object x = "hi";
ITypesOfCapturedArgs res = () -> x;
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
ITypesOfCapturedArgs lam = (ITypesOfCapturedArgs) in.readObject();
Object val = lam.get();
if (!val.equals("hi")) {
throw new IllegalArgumentException("Expected 'hi'");
}
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface IVariableAssignmentTarget extends Serializable {
String get();
}
class TESTVariableAssignmentTarget {
public TESTVariableAssignmentTarget() {
}
public void write(ObjectOutput out) throws IOException {
IVariableAssignmentTarget res2 = () -> "bar";
IVariableAssignmentTarget res1 = () -> "fu";
out.writeObject(res1);
out.writeObject(res2);
}
public void readCheck(ObjectInput in) throws Exception {
IVariableAssignmentTarget lam = (IVariableAssignmentTarget) in.readObject();
Object val = lam.get();
if (!val.equals("fu")) {
throw new IllegalArgumentException("Expected 'fu'");
}
lam = (IVariableAssignmentTarget) in.readObject();
val = lam.get();
if (!val.equals("bar")) {
throw new IllegalArgumentException("Expected 'bar'");
}
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface INameOfCapturedArgs extends Serializable {
int get();
}
class TESTNameOfCapturedArgs {
public TESTNameOfCapturedArgs() {
}
public void write(ObjectOutput out) throws IOException {
int x = 44;
INameOfCapturedArgs res = () -> x;
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
INameOfCapturedArgs lam = (INameOfCapturedArgs) in.readObject();
int val = lam.get();
if (val != 44) {
throw new IllegalArgumentException("Expected 44");
}
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface IOrderOfCapturedArgs extends Serializable {
String get();
}
class TESTOrderOfCapturedArgs {
public TESTOrderOfCapturedArgs() {
}
public void write(ObjectOutput out) throws IOException {
String a = "fu";
String b = "bar";
IOrderOfCapturedArgs res = () -> a + b;
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
IOrderOfCapturedArgs lam = (IOrderOfCapturedArgs) in.readObject();
Object val = lam.get();
if (!val.equals("fubar")) {
throw new IllegalArgumentException("Expected 'fubar'");
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface ITargetName extends Serializable {
String get();
}
class TESTTargetName {
public TESTTargetName() {
}
public void write(ObjectOutput out) throws IOException {
ITargetName res = () -> "fubar";
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
ITargetName lam = (ITargetName) in.readObject();
Object val = lam.get();
if (!val.equals("fubar")) {
throw new IllegalArgumentException("Expected 'fubar'");
}
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
import java.util.function.*;
class TESTTargetType {
public TESTTargetType() {
}
public void write(ObjectOutput out) throws IOException {
Object res = (Function<String, Boolean> & Serializable) ((str) -> str.length() > 3);
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
in.readObject();
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface ITypesOfCapturedArgs extends Serializable {
Object get();
}
class TESTTypesOfCapturedArgs {
public TESTTypesOfCapturedArgs() {
}
public void write(ObjectOutput out) throws IOException {
String x = "hi";
ITypesOfCapturedArgs res = () -> x;
out.writeObject(res);
}
public void readCheck(ObjectInput in) throws Exception {
ITypesOfCapturedArgs lam = (ITypesOfCapturedArgs) in.readObject();
Object val = lam.get();
if (!val.equals("hi")) {
throw new IllegalArgumentException("Expected 'hi'");
}
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.*;
interface IVariableAssignmentTarget extends Serializable {
String get();
}
class TESTVariableAssignmentTarget {
public TESTVariableAssignmentTarget() {
}
public void write(ObjectOutput out) throws IOException {
IVariableAssignmentTarget res1 = () -> "fu";
IVariableAssignmentTarget res2 = () -> "bar";
out.writeObject(res1);
out.writeObject(res2);
}
public void readCheck(ObjectInput in) throws Exception {
IVariableAssignmentTarget lam = (IVariableAssignmentTarget) in.readObject();
Object val = lam.get();
if (!val.equals("fu")) {
throw new IllegalArgumentException("Expected 'fu'");
}
lam = (IVariableAssignmentTarget) in.readObject();
val = lam.get();
if (!val.equals("bar")) {
throw new IllegalArgumentException("Expected 'bar'");
}
}
}