proguard can't find reference method - java

how can i solve this warnings ?
the "invoke" method referenced below,
public final native Object invoke(Object[] paramArrayOfObject) throws Throwable;
so, i must ignore this (just my opinion). but ignorewarnings are not helpful
does anybody knows how ignore this warnings?
ProGuard, version 4.9
Reading program jar [C:\Users\Las Plagas\Desktop\wbsys.jar]
Reading library jar [C:\Program Files\Java\jre7\lib\rt.jar]
Warning: WebAnalysisMain: can't find referenced method 'void invoke(java.lang.Class)' in class java.lang.invoke.MethodHandle
Warning: there were 1 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code or update the library versions.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
Please correct the above warnings first.

Related

How to use protobuf with proguard

After adding protobuf dependency to a project that is using proguard for releases I run into the following issues:
Warning: ***.***.Api: can't find referenced method 'com.google.protobuf.Descriptors$FileDescriptor getDescriptor()' in library class com.google.protobuf.AnyProto
Warning: ***.***.Api$Information: can't find referenced method 'com.google.protobuf.Any$Builder toBuilder()' in library class com.google.protobuf.Any
Warning: ***.***.Api$Information: can't find referenced method 'com.google.protobuf.Any$Builder mergeFrom(com.google.protobuf.Any)' in library class com.google.protobuf.Any$Builder
Warning: ***.***.Api$Information: can't find referenced method 'com.google.protobuf.Any buildPartial()' in library class com.google.protobuf.Any$Builder
Warning: ***.***.Api$Information$Builder: can't find referenced method 'com.google.protobuf.Any build()' in library class com.google.protobuf.Any$Builder
Warning: ***.***.Api$Information$Builder: can't find referenced method 'com.google.protobuf.Any$Builder mergeFrom(com.google.protobuf.Any)' in library class com.google.protobuf.Any$Builder
Warning: ***.***.Api$Information$Builder: can't find referenced method 'com.google.protobuf.Any buildPartial()' in library class com.google.protobuf.Any$Builder
Warning: ***.***Service: can't find referenced method 'com.google.protobuf.Any pack(com.google.protobuf.Message)' in library class com.google.protobuf.Any
In my case the problem was that another dependency already had a transitive dependency on protobuf-javalite and it conflicted with the protobuf-java I was adding.
As per https://github.com/protocolbuffers/protobuf/issues/8104#issuecomment-887076083:
protobuf-java and protobuf-javalite should
never be included in the same project [...] if you're using Gradle, we
recommend an approach like this:
https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps
Telling the system to exclude protobuf-javalite because you explicitly
depend on protobuf-java is technically OK, but this might have
negative side effects to performance or code size on mobile platforms,
it also might be totally fine for you, your mileage may vary.
The problem was solved for me after excluding protobuf-javalite like this
configurations {
all*.exclude group: 'com.google.protobuf', module: 'protobuf-javalite'
}

Can't find referenced method 'java.lang.Object injectMembers(dagger.MembersInjector,java.lang.Object)

Recently I upgrade Dagger 2.13 to 2.19, I have the below compile error at Proguard stage of this warning.
Warning: com.mypackage.MyClass_Factory: can't find referenced method 'java.lang.Object injectMembers(dagger.MembersInjector,java.lang.Object)' in program class dagger.internal.MembersInjectors
This also happens from Dagger 2.14.1 onwards. This happens only to MyClass which is in a library I include.
If I use
-dontwarn com.mypackage.MyClass_Factory
Then it will crash on runtime
java.lang.NoSuchMethodError: No static method injectMembers(Ldagger/MembersInjector;Ljava/lang/Object;)Ljava/lang/Object; in class Ldagger/internal/MembersInjectors; or its super classes (declaration of 'dagger.internal.MembersInjectors' appears in MyClass
Which means the warning from Proguard is a legit warning I should take care.
I search and found the issue is reported in https://github.com/google/dagger/pull/950#issuecomment-353223029
The solution by #ronshapiro is
You should shade the dagger.internal from one (or both) of the libraries. The old one is probably easiest
What does shade the dagger.internal means? How to solve my problem?

Suppress "Cannot be resolved to a type" for specific keyword in Type

I am writing a java program that compiles using generated class files (as in .java files) using my own code generator. The naming convention I am using for these generated files is public class classname_generated {}.
e.g. Foo_generated foo;
The problem is, because these generated files are only added to the project source when my code generator creates them before compile (and then removed after compile) Eclipse serves up the warning "classname_generated cannot be resolved to a type" whenever I declare an instance, now I am not bothered that the Eclipse doesn't give me the nice little list of members of the class when write my code, but it would be nice if I could suppress the "could not be resolved to a type" warning.
My question is, is it possible to suppress those warnings for only code that follows the pattern of 'classname_generated'? i.e. only suppress it for code like Foo_generated of Bar_generated

GWT Compiler : when is a compilation error fatal?

I'm trying to understand more about how GWT compilation works.
More specifically, I want to know how does GWT decide that a particular error is fatal, and the app compilation should fail because of it, and how does it decide that compilation is successful, even though there are compilation errors.
The reason I'm asking is that it's very difficult to distinguish legitimate errors in my log when doing a search, from ones that don't seem to cause any problem.
I'm talking about GWT 2.7 and GWT 2.8 (which I've seen they exhibit the same behavior).
Also, I'm using GWTP 1.5.3, if this is relevant somewhat.
A concrete example: I have this error in my logs:
Tracing compile failure path for type 'myApp.ClientModule'
Errors in 'file:/E:/data/.../myApp/ClientModule.java'
Line 24: No source code is available for type myApp.client.ServicesProvidersModuleGen; did you forget to inherit a required module?
Checked 1 dependencies for errors.
The error above does not make my app to fail compilation, and myApp works just fine (the class is something that registers some GIN bindings, which also work).
Why didn't GWT failed my compilation when it encountered that error?
Additionally, I also have other errors such as:
Errors in 'com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java'
Line 102: No source code is available for type javax.validation.ValidationException; did you forget to inherit a required module?
Line 177: No source code is available for type javax.validation.ConstraintValidator<A,T>; did you forget to inherit a required module?
Line 153: No source code is available for type javax.validation.groups.Default; did you forget to inherit a required module?
Line 302: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?
These errors also don't fail my compilation. Why?
Edit1: forgot to add.
I'm tempted to guess that compilation fails when the error is in something directly reachable from an entry point, and that compilation is OK when that code is not reachable.
However, I have the counter-example of code with annotations.
I have code that IS reachable from the entry point, and has annotations whose source code is not available, and yet the compilation succeeds (although this is the only exception that I could find so far).
Your analysis is good.
GWT will scan the entire classpath, ignoring everything not in the source path and "rebasing" super-sources. During that scan, it emits the kind of error you saw, but only when code will reach the missing sources (from entry points) the error will become fatal. Annotations are no exception, but code will never actually reach them as their just metadata (unless you implement an #interface, which Java allows). Annotations can be used by generators though, in which case they can fail the build.
Note that if you use -failOnError (or -strict, which is an alias), then all errors are fatal. You should aim for turning this on IMO.

Using antlr-3.4-complete.jar in Eclipse is slow

I dived into Antlr a while ago, but I've noticed that the compile times are unbelievably long (the progress will sit at 100% for 5 minutes while Eclipse complains about Antlr). When all Antlr references are removed, but antlr-3.4-complete.jar is still included, the problem persists. As soon as it is removed from the build path, the compile time goes back down to infinitesimal.
Also, compiling more than once in a Eclipse session causes an out of memory error.
What could be going on? Is it really recompiling the whole ANTLR library every time? How can I compile it in a timely manner?
Edit: The complaints eclipse gives are warning about inner classes (as shown below).
[2012-08-13 22:23:39 - HoloCalc] Dx warning: Ignoring InnerClasses
attribute for an anonymous inner class
(antlr.TokenStreamRewriteEngine$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.

Categories