jdk/test/java/beans/XMLEncoder/Test8013557.java
author lana
Tue, 23 May 2017 21:11:42 +0000
changeset 45187 331a6542b5b8
parent 17896 271991446515
permissions -rw-r--r--
Added tag jdk-10+7 for changeset d554736d963e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17896
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     1
/*
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     4
 *
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     8
 *
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    13
 * accompanied this code).
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    14
 *
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    18
 *
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    21
 * questions.
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    22
 */
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    23
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    24
/*
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    25
 * @test
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    26
 * @bug 8013557
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    27
 * @summary Tests beans with public fields
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    29
 */
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    30
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    31
public class Test8013557 extends AbstractTest {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    32
    public static void main(String[] args) {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    33
        new Test8013557().test(true);
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    34
    }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    35
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    36
    protected Object getObject() {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    37
        return new Bean(new Value("something"));
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    38
    }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    39
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    40
    @Override
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    41
    protected Object getAnotherObject() {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    42
        return new Bean(new Value());
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    43
    }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    44
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    45
    public static class Bean {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    46
        public Value value;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    47
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    48
        public Bean() {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    49
            this.value = new Value();
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    50
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    51
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    52
        public Bean(Value value) {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    53
            this.value = value;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    54
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    55
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    56
        public void setValue(Value value) {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    57
            this.value = value;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    58
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    59
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    60
        public Value getValue() {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    61
            return this.value;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    62
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    63
    }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    64
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    65
    public static class Value {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    66
        private String string;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    67
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    68
        public Value() {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    69
            this.string = "default";
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    70
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    71
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    72
        public Value(String value) {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    73
            this.string = value;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    74
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    75
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    76
        public void setString(String string) {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    77
            this.string = string;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    78
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    79
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    80
        public String getString() {
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    81
            return this.string;
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    82
        }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    83
    }
271991446515 8013557: XMLEncoder in 1.7 can't encode objects initialized in no argument constructor
malenkov
parents:
diff changeset
    84
}