SSL Boxing.java
Interaktion und PortierbarkeitJAVA
/* * Copyright (c) 2003, 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 4889342 * @summary This test verifies that when a primitive boolean value is * passed by a dynamic proxy class to an invocation handler, it is * boxed as one of the canonical Boolean instances (Boolean.TRUE or * Boolean.FALSE). This test also exercises a dynamic proxy class's * boxing of all primitive types. * @author Peter Jones * * @run main Boxing
*/
publicstaticvoid main(String[] args) {
(new Boxing()).run();
System.err.println("TEST PASSED");
}
privatevoid run() {
Random random = new Random(42); // ensure consistent test domain
Test proxy = (Test) Proxy.newProxyInstance(
Test.class.getClassLoader(), newClass<?>[] { Test.class }, new TestHandler());
for (int rep = 0; rep < REPS; rep++) {
b = (byte) random.nextInt();
c = (char) random.nextInt();
d = random.nextDouble();
f = random.nextFloat();
i = random.nextInt();
j = random.nextLong();
s = (short) random.nextInt();
z = random.nextBoolean();
proxy.m(b,c,d,f,i,j,s,z);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.