proguard.classfile.util.WarningPrinter Java Examples
The following examples show how to use
proguard.classfile.util.WarningPrinter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSR310Converter.java From proguard with GNU General Public License v2.0 | 5 votes |
/** * Create a new JSR310Converter instance. */ public JSR310Converter(ClassPool programClassPool, ClassPool libraryClassPool, WarningPrinter warningPrinter, ClassVisitor modifiedClassVisitor, InstructionVisitor extraInstructionVisitor) { super(programClassPool, libraryClassPool, warningPrinter, modifiedClassVisitor, extraInstructionVisitor); TypeReplacement[] typeReplacements = new TypeReplacement[] { // java.time package has been added in Java 8 replace("java/time/**", "org/threeten/bp/<1>"), }; MethodReplacement[] methodReplacements = new MethodReplacement[] { // all classes in java.time.** are converted to // org.threeeten.bp.**. replace("java/time/**", "**", "**", "org/threeten/bp/<1>", "<1>", "<1>"), }; setTypeReplacements(typeReplacements); setMethodReplacements(methodReplacements); }
Example #2
Source File: KotlinMetadataAsserter.java From proguard with GNU General Public License v2.0 | 5 votes |
public void execute(ClassPool programClassPool, ClassPool libraryClassPool, ResourceFilePool resourceFilePool, WarningPrinter warningPrinter) { Reporter reporter = new DefaultReporter(warningPrinter); MyKotlinMetadataAsserter kotlinMetadataAsserter = new MyKotlinMetadataAsserter(reporter, DEFAULT_CONSTRAINTS); reporter.setErrorMessage("Warning: Kotlin metadata errors encountered in %s. Not processing the metadata for this class."); programClassPool.classesAccept(new ReferencedKotlinMetadataVisitor(kotlinMetadataAsserter)); libraryClassPool.classesAccept(new ReferencedKotlinMetadataVisitor(kotlinMetadataAsserter)); reporter.setErrorMessage("Warning: Kotlin module errors encountered in module %s. Not processing the metadata for this module."); resourceFilePool.resourceFilesAccept( new ResourceFileProcessingFlagFilter(0, ProcessingFlags.DONT_PROCESS_KOTLIN_MODULE, kotlinMetadataAsserter)); }
Example #3
Source File: FullyQualifiedClassNameChecker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Creates a new FullyQualifiedClassNameChecker. */ public FullyQualifiedClassNameChecker(ClassPool programClassPool, ClassPool libraryClassPool, WarningPrinter notePrinter) { this.programClassPool = programClassPool; this.libraryClassPool = libraryClassPool; this.notePrinter = notePrinter; }
Example #4
Source File: DescriptorKeepChecker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Creates a new DescriptorKeepChecker. */ public DescriptorKeepChecker(ClassPool programClassPool, ClassPool libraryClassPool, WarningPrinter notePrinter) { this.programClassPool = programClassPool; this.libraryClassPool = libraryClassPool; this.notePrinter = notePrinter; }
Example #5
Source File: ClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Creates a new DataEntryClassFilter for reading the specified * Clazz objects. */ public ClassReader(boolean isLibrary, boolean skipNonPublicLibraryClasses, boolean skipNonPublicLibraryClassMembers, WarningPrinter warningPrinter, ClassVisitor classVisitor) { this.isLibrary = isLibrary; this.skipNonPublicLibraryClasses = skipNonPublicLibraryClasses; this.skipNonPublicLibraryClassMembers = skipNonPublicLibraryClassMembers; this.warningPrinter = warningPrinter; this.classVisitor = classVisitor; }
Example #6
Source File: GsonContext.java From proguard with GNU General Public License v2.0 | 4 votes |
/** * Sets up the Gson context for the given program class pool. * Notes will be printed to the given printer if provided. * * @param programClassPool the program class pool * @param libraryClassPool the library class pool * @param warningPrinter the optional warning printer to which notes * can be printed. */ public void setupFor(ClassPool programClassPool, ClassPool libraryClassPool, WarningPrinter warningPrinter) { // Only apply remaining optimizations to classes that are not part of // Gson itself. ClassPool filteredClasses = new ClassPool(); programClassPool.classesAccept( new ClassNameFilter("!com/google/gson/**", new ClassPoolFiller(filteredClasses))); // Find all GsonBuilder invocations. gsonRuntimeSettings = new GsonRuntimeSettings(); GsonBuilderInvocationFinder gsonBuilderInvocationFinder = new GsonBuilderInvocationFinder( programClassPool, libraryClassPool, gsonRuntimeSettings, new ClassPoolFiller(gsonRuntimeSettings.instanceCreatorClassPool), new ClassPoolFiller(gsonRuntimeSettings.typeAdapterClassPool)); filteredClasses.classesAccept( new AllMethodVisitor( new AllAttributeVisitor( new AllInstructionVisitor(gsonBuilderInvocationFinder)))); // Find all Gson invocations. gsonDomainClassPool = new ClassPool(); GsonDomainClassFinder domainClassFinder = new GsonDomainClassFinder(gsonRuntimeSettings, gsonDomainClassPool, warningPrinter); filteredClasses.accept( new AllClassVisitor( new AllMethodVisitor( new AllAttributeVisitor( new AllInstructionVisitor( new MultiInstructionVisitor( new GsonSerializationInvocationFinder(programClassPool, libraryClassPool, domainClassFinder, warningPrinter), new GsonDeserializationInvocationFinder(programClassPool, libraryClassPool, domainClassFinder, warningPrinter))))))); }
Example #7
Source File: DuplicateResourceFilePrinter.java From proguard with GNU General Public License v2.0 | 4 votes |
/** * Creates a new DuplicateResourceFilePrinter. */ public DuplicateResourceFilePrinter(WarningPrinter notePrinter) { this.notePrinter = notePrinter; }
Example #8
Source File: DefaultReporter.java From proguard with GNU General Public License v2.0 | 4 votes |
DefaultReporter(WarningPrinter warningPrinter) { this.warningPrinter = warningPrinter; count = 0; }
Example #9
Source File: InputReader.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Fills the given program class pool and library class pool by reading * class files, based on the current configuration. */ public void execute(ClassPool programClassPool, ClassPool libraryClassPool) throws IOException { // Check if we have at least some input classes. if (configuration.programJars == null) { throw new IOException("The input is empty. You have to specify one or more '-injars' options"); } // Perform some sanity checks on the class paths. checkInputOutput(configuration.libraryJars, configuration.programJars); checkInputOutput(configuration.programJars, configuration.programJars); WarningPrinter warningPrinter = new WarningPrinter(System.err, configuration.warn); WarningPrinter notePrinter = new WarningPrinter(System.out, configuration.note); DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter); // Read the program class files. // Prepare a data entry reader to filter all classes, // which are then decoded to classes by a class reader, // which are then put in the class pool by a class pool filler. readInput("Reading program ", configuration.programJars, new ClassFilter( new ClassReader(false, configuration.skipNonPublicLibraryClasses, configuration.skipNonPublicLibraryClassMembers, warningPrinter, new ClassPresenceFilter(programClassPool, duplicateClassPrinter, new ClassPoolFiller(programClassPool))))); // Check if we have at least some input classes. if (programClassPool.size() == 0) { throw new IOException("The input doesn't contain any classes. Did you specify the proper '-injars' options?"); } // Read the library class files, if any. if (configuration.libraryJars != null) { // Prepare a data entry reader to filter all classes, // which are then decoded to classes by a class reader, // which are then put in the class pool by a class pool filler. readInput("Reading library ", configuration.libraryJars, new ClassFilter( new ClassReader(true, configuration.skipNonPublicLibraryClasses, configuration.skipNonPublicLibraryClassMembers, warningPrinter, new ClassPresenceFilter(programClassPool, duplicateClassPrinter, new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter, new ClassPoolFiller(libraryClassPool)))))); } // Print out a summary of the notes, if necessary. int noteCount = notePrinter.getWarningCount(); if (noteCount > 0) { System.err.println("Note: there were " + noteCount + " duplicate class definitions."); } // Print out a summary of the warnings, if necessary. int warningCount = warningPrinter.getWarningCount(); if (warningCount > 0) { System.err.println("Warning: there were " + warningCount + " classes in incorrectly named files."); System.err.println(" You should make sure all file names correspond to their class names."); System.err.println(" The directory hierarchies must correspond to the package hierarchies."); if (!configuration.ignoreWarnings) { System.err.println(" If you don't mind the mentioned classes not being written out,"); System.err.println(" you could try your luck using the '-ignorewarnings' option."); throw new IOException("Please correct the above warnings first."); } } }
Example #10
Source File: DuplicateClassPrinter.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Creates a new DuplicateClassVisitor. */ public DuplicateClassPrinter(WarningPrinter notePrinter) { this.notePrinter = notePrinter; }
Example #11
Source File: KeepClassMemberChecker.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Creates a new KeepClassMemberChecker. */ public KeepClassMemberChecker(WarningPrinter notePrinter) { this.notePrinter = notePrinter; }
Example #12
Source File: InputReader.java From proguard with GNU General Public License v2.0 | 4 votes |
/** * Fills the given program class pool and library class pool by reading * class files, based on the current configuration. */ public void execute(ClassPool programClassPool, ClassPool libraryClassPool) throws IOException { WarningPrinter warningPrinter = new WarningPrinter(System.err, configuration.warn); WarningPrinter notePrinter = new WarningPrinter(System.out, configuration.note); DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter); // Read the program class files. // Prepare a data entry reader to filter all classes, // which are then decoded to classes by a class reader, // which are then put in the class pool by a class pool filler. readInput("Reading program ", configuration.programJars, new ClassFilter( new ClassReader(false, configuration.skipNonPublicLibraryClasses, configuration.skipNonPublicLibraryClassMembers, warningPrinter, new ClassPresenceFilter(programClassPool, duplicateClassPrinter, new ClassPoolFiller(programClassPool))))); // Check if we have at least some input classes. if (programClassPool.size() == 0) { throw new IOException("The input doesn't contain any classes. Did you specify the proper '-injars' options?"); } // Read the library class files, if any. if (configuration.libraryJars != null) { // Prepare a data entry reader to filter all classes, // which are then decoded to classes by a class reader, // which are then put in the class pool by a class pool filler. readInput("Reading library ", configuration.libraryJars, new ClassFilter( new ClassReader(true, configuration.skipNonPublicLibraryClasses, configuration.skipNonPublicLibraryClassMembers, warningPrinter, new ClassPresenceFilter(programClassPool, duplicateClassPrinter, new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter, new ClassPoolFiller(libraryClassPool)))))); } // Print out a summary of the notes, if necessary. int noteCount = notePrinter.getWarningCount(); if (noteCount > 0) { System.err.println("Note: there were " + noteCount + " duplicate class definitions."); System.err.println(" (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)"); } // Print out a summary of the warnings, if necessary. int warningCount = warningPrinter.getWarningCount(); if (warningCount > 0) { System.err.println("Warning: there were " + warningCount + " classes in incorrectly named files."); System.err.println(" You should make sure all file names correspond to their class names."); System.err.println(" The directory hierarchies must correspond to the package hierarchies."); System.err.println(" (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)"); if (!configuration.ignoreWarnings) { System.err.println(" If you don't mind the mentioned classes not being written out,"); System.err.println(" you could try your luck using the '-ignorewarnings' option."); throw new IOException("Please correct the above warnings first."); } } }
Example #13
Source File: InputReader.java From bazel with Apache License 2.0 | 4 votes |
/** * Fills the given program class pool and library class pool by reading * class files, based on the current configuration. */ public void execute(ClassPool programClassPool, ClassPool libraryClassPool) throws IOException { WarningPrinter warningPrinter = new WarningPrinter(System.err, configuration.warn); WarningPrinter notePrinter = new WarningPrinter(System.out, configuration.note); DuplicateClassPrinter duplicateClassPrinter = new DuplicateClassPrinter(notePrinter); // Read the program class files. // Prepare a data entry reader to filter all classes, // which are then decoded to classes by a class reader, // which are then put in the class pool by a class pool filler. readInput("Reading program ", configuration.programJars, new ClassFilter( new ClassReader(false, configuration.skipNonPublicLibraryClasses, configuration.skipNonPublicLibraryClassMembers, warningPrinter, new ClassPresenceFilter(programClassPool, duplicateClassPrinter, new ClassPoolFiller(programClassPool))))); // Check if we have at least some input classes. if (programClassPool.size() == 0) { throw new IOException("The input doesn't contain any classes. Did you specify the proper '-injars' options?"); } // Read the library class files, if any. if (configuration.libraryJars != null) { // Prepare a data entry reader to filter all classes, // which are then decoded to classes by a class reader, // which are then put in the class pool by a class pool filler. readInput("Reading library ", configuration.libraryJars, new ClassFilter( new ClassReader(true, configuration.skipNonPublicLibraryClasses, configuration.skipNonPublicLibraryClassMembers, warningPrinter, new ClassPresenceFilter(programClassPool, duplicateClassPrinter, new ClassPresenceFilter(libraryClassPool, duplicateClassPrinter, new ClassPoolFiller(libraryClassPool)))))); } // Print out a summary of the notes, if necessary. int noteCount = notePrinter.getWarningCount(); if (noteCount > 0) { System.err.println("Note: there were " + noteCount + " duplicate class definitions."); System.err.println(" (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)"); } // Print out a summary of the warnings, if necessary. int warningCount = warningPrinter.getWarningCount(); if (warningCount > 0) { System.err.println("Warning: there were " + warningCount + " classes in incorrectly named files."); System.err.println(" You should make sure all file names correspond to their class names."); System.err.println(" The directory hierarchies must correspond to the package hierarchies."); System.err.println(" (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)"); if (!configuration.ignoreWarnings) { System.err.println(" If you don't mind the mentioned classes not being written out,"); System.err.println(" you could try your luck using the '-ignorewarnings' option."); throw new IOException("Please correct the above warnings first."); } } }
Example #14
Source File: MemberNameConflictFixer.java From java-n-IDE-for-Android with Apache License 2.0 | 3 votes |
/** * Creates a new MemberNameConflictFixer. * @param allowAggressiveOverloading a flag that specifies whether class * members can be overloaded aggressively. * @param descriptorMap the map of descriptors to * [new name - old name] maps. * @param warningPrinter an optional warning printer to which * warnings about conflicting name * mappings can be printed. * @param memberObfuscator the obfuscator that can assign new * names to members with conflicting * names. */ public MemberNameConflictFixer(boolean allowAggressiveOverloading, Map descriptorMap, WarningPrinter warningPrinter, MemberObfuscator memberObfuscator) { this.allowAggressiveOverloading = allowAggressiveOverloading; this.descriptorMap = descriptorMap; this.warningPrinter = warningPrinter; this.memberObfuscator = memberObfuscator; }
Example #15
Source File: MappingKeeper.java From java-n-IDE-for-Android with Apache License 2.0 | 3 votes |
/** * Creates a new MappingKeeper. * @param classPool the class pool in which class names and class * member names have to be mapped. * @param warningPrinter the optional warning printer to which warnings * can be printed. */ public MappingKeeper(ClassPool classPool, WarningPrinter warningPrinter) { this.classPool = classPool; this.warningPrinter = warningPrinter; }