WarnSerializableLambda.java revision 3711:3fc90eaaf922
143809Sjkh/* 243809Sjkh * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 343809Sjkh * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 443809Sjkh * 543809Sjkh * This code is free software; you can redistribute it and/or modify it 643809Sjkh * under the terms of the GNU General Public License version 2 only, as 743809Sjkh * published by the Free Software Foundation. 843809Sjkh * 943809Sjkh * This code is distributed in the hope that it will be useful, but WITHOUT 1059674Ssheldonh * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1159674Ssheldonh * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1259674Ssheldonh * version 2 for more details (a copy is included in the LICENSE file that 1354949Ssheldonh * accompanied this code). 1443809Sjkh * 1543809Sjkh * You should have received a copy of the GNU General Public License version 1650472Speter * 2 along with this work; if not, write to the Free Software Foundation, 1743809Sjkh * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1843809Sjkh * 1948290Sjseger * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2043809Sjkh * or visit www.oracle.com if you need additional information or have any 2143809Sjkh * questions. 2243809Sjkh */ 2348785Siwasaki 2448785Siwasaki// key: compiler.warn.access.to.member.from.serializable.element 2548785Siwasaki// options: -XDwarnOnAccessToMembers 2643809Sjkh 2743809Sjkhimport java.io.Serializable; 2854041Simp 2943809Sjkhpublic class WarnSerializableLambda { 3048554Shosokawa private void m1() { 3158979Siwasaki new SerializableClass() { 3243809Sjkh @Override 3343809Sjkh public void m() { 3443809Sjkh packageField = ""; 3543809Sjkh } 3643809Sjkh }; 3743809Sjkh } 3843809Sjkh 3943809Sjkh String packageField; 4048880Sjkh 4143809Sjkh class SerializableClass implements Serializable { 4248842Sjkh public void m() {} 4348842Sjkh } 4443809Sjkh} 4545542Sdes