0N/A/*
196N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6921644
0N/A * @summary Tests references to cached integer
0N/A * @author Sergey Malenkov
0N/A */
0N/A
0N/Aimport java.beans.ConstructorProperties;
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.List;
0N/A
0N/Apublic final class Test6921644 extends AbstractTest {
0N/A public static void main(String[] args) {
0N/A new Test6921644().test(true);
0N/A }
0N/A
0N/A protected Object getObject() {
0N/A Owner<Author> o = new Owner<Author>(100); // it works if ID >= 128
0N/A
0N/A Category c = new Category(o);
0N/A
0N/A Document d1 = new Document(o);
0N/A Document d2 = new Document(o);
0N/A Document d3 = new Document(o);
0N/A
0N/A Author a1 = new Author(o);
0N/A Author a2 = new Author(o);
0N/A Author a3 = new Author(o);
0N/A
0N/A o.getList().add(a1);
0N/A o.getList().add(a2);
0N/A o.getList().add(a3);
0N/A
0N/A a3.setRef(o.getId());
0N/A
0N/A d2.setCategory(c);
0N/A d3.setCategory(c);
0N/A
0N/A a1.addDocument(d1);
0N/A a1.addDocument(d2);
0N/A a3.addDocument(d3);
0N/A
0N/A c.addDocument(d2);
0N/A c.addDocument(d3);
0N/A
0N/A return o;
0N/A }
0N/A
0N/A public static class Owner<T> {
0N/A private int id;
0N/A private List<T> list = new ArrayList<T>();
0N/A
0N/A @ConstructorProperties("id")
0N/A public Owner(int id) {
0N/A this.id = id;
0N/A }
0N/A
0N/A public int getId() {
0N/A return this.id;
0N/A }
0N/A
0N/A public List<T> getList() {
0N/A return this.list;
0N/A }
0N/A
0N/A public void setList(List<T> list) {
0N/A this.list = list;
0N/A }
0N/A }
0N/A
0N/A public static class Author {
0N/A private int id;
0N/A private int ref;
0N/A private Owner owner;
0N/A private List<Document> list = new ArrayList<Document>();
0N/A
0N/A @ConstructorProperties("owner")
0N/A public Author(Owner<Author> owner) {
0N/A this.owner = owner;
0N/A this.id = owner.getId();
0N/A }
0N/A
0N/A public Owner getOwner() {
0N/A return this.owner;
0N/A }
0N/A
0N/A public Integer getId() {
0N/A return this.id;
0N/A }
0N/A
0N/A public void setId(Integer id) {
0N/A this.id = id;
0N/A }
0N/A
0N/A public Integer getRef() {
0N/A return this.ref;
0N/A }
0N/A
0N/A public void setRef(Integer ref) {
0N/A this.ref = ref;
0N/A }
0N/A
0N/A public List<Document> getList() {
0N/A return this.list;
0N/A }
0N/A
0N/A public void setList(List<Document> list) {
0N/A this.list = list;
0N/A }
0N/A
0N/A public void addDocument(Document document) {
0N/A this.list.add(document);
0N/A document.setAuthor(this);
0N/A }
0N/A }
0N/A
0N/A public static class Category {
0N/A private Owner owner;
0N/A private List<Document> list = new ArrayList<Document>();
0N/A
0N/A @ConstructorProperties("owner")
0N/A public Category(Owner owner) {
0N/A this.owner = owner;
0N/A }
0N/A
0N/A public Owner getOwner() {
0N/A return this.owner;
0N/A }
0N/A
0N/A public List<Document> getList() {
0N/A return this.list;
0N/A }
0N/A
0N/A public void setList(List<Document> list) {
0N/A this.list = list;
0N/A }
0N/A
0N/A public void addDocument(Document document) {
0N/A this.list.add(document);
0N/A document.setCategory(this);
0N/A }
0N/A }
0N/A
0N/A public static class Document {
0N/A private Owner owner;
0N/A private Author author;
0N/A private Category category;
0N/A
0N/A @ConstructorProperties("owner")
0N/A public Document(Owner owner) {
0N/A this.owner = owner;
0N/A }
0N/A
0N/A public Owner getOwner() {
0N/A return this.owner;
0N/A }
0N/A
0N/A public Author getAuthor() {
0N/A return this.author;
0N/A }
0N/A
0N/A public void setAuthor(Author author) {
0N/A this.author = author;
0N/A }
0N/A
0N/A public Category getCategory() {
0N/A return this.category;
0N/A }
0N/A
0N/A public void setCategory(Category category) {
0N/A this.category = category;
0N/A }
0N/A }
0N/A}
0N/A