// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. package com.android.tools.r8.utils; import com.android.tools.r8.Resource; import com.android.tools.r8.errors.CompilationError; import com.android.tools.r8.graph.ClassKind; import com.android.tools.r8.graph.DexApplication; import com.android.tools.r8.graph.DexLibraryClass; import com.android.tools.r8.logging.Log; import java.util.function.Supplier; /** Represents a collection of library classes. */ public class LibraryClassCollection extends ClassMap { public LibraryClassCollection(ClassProvider classProvider) { super(null, classProvider); } @Override DexLibraryClass resolveClassConflict(DexLibraryClass a, DexLibraryClass b) { if (a.origin != Resource.Kind.CLASSFILE || b.origin != Resource.Kind.CLASSFILE) { // We only support conflicts for classes both coming from jar files. throw new CompilationError( "Library type already present: " + a.type.toSourceString()); } if (Log.ENABLED) { Log.warn(DexApplication.class, "Class `%s` was specified twice as a library type.", a.type.toSourceString()); } return a; } @Override Supplier getTransparentSupplier(DexLibraryClass clazz) { return clazz; } @Override ClassKind getClassKind() { return ClassKind.LIBRARY; } @Override public String toString() { return "library classes: " + super.toString(); } }