1 // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file 2 // for details. All rights reserved. Use of this source code is governed by a 3 // BSD-style license that can be found in the LICENSE file. 4 package memberrebinding; 5 6 import java.util.ArrayList; 7 import java.util.Arrays; 8 9 public class ClassExtendsLibraryClass extends ArrayList<String> { 10 11 public void methodThatAddsHelloWorld() { 12 // call add on this type, so it gets rebound. 13 add("hello"); 14 // call it on list to make the methodid available. 15 addOnArrayList(this, "world"); 16 } 17 18 private static <T> void addOnArrayList(ArrayList<T> list, T item) { 19 list.add(item); 20 } 21 22 public void methodThatAddsHelloWorldUsingAddAll() { 23 // call this only on this type, so that it cannot be rebound to the interface. 24 String[] words = new String[]{"hello", "world"}; 25 addAll(Arrays.asList(words)); 26 } 27 28 } 29