forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Dagger 2.53.1
Source code:
@Singleton
class StaticDataSource @Inject constructor() {
}Android Lint:
StaticDataSource_Factory.java:32: Error: Access to private field INSTANCE of class InstanceHolder requires synthetic accessor [SyntheticAccessor]
return InstanceHolder.INSTANCE;
~~~~~~~~
Explanation for issues of type "SyntheticAccessor":
A private inner class which is accessed from the outer class will force the
compiler to insert a synthetic accessor; this means that you are causing
extra overhead. This is not important in small projects, but is important
for large apps running up against the 64K method handle limit, and
especially for libraries where you want to make sure your library is as
small as possible for the cases where your library is used in an app
running up against the 64K limit.
1 errors, 0 warnings
I think the PRIVATE for the INSTANCE field should be default visible here?
dagger/java/dagger/internal/codegen/writing/FactoryGenerator.java
Lines 160 to 173 in d33c3e7
| private TypeSpec staticInstanceHolderType(ContributionBinding binding) { | |
| ClassName generatedClassName = generatedClassNameForBinding(binding); | |
| FieldSpec.Builder instanceHolderFieldBuilder = | |
| FieldSpec.builder(generatedClassName, "INSTANCE", PRIVATE, STATIC, FINAL) | |
| .initializer("new $T()", generatedClassName); | |
| if (!bindingTypeElementTypeVariableNames(binding).isEmpty()) { | |
| // If the factory has type parameters, ignore them in the field declaration & initializer | |
| instanceHolderFieldBuilder.addAnnotation(suppressWarnings(RAWTYPES)); | |
| } | |
| return TypeSpec.classBuilder(instanceHolderClassName(binding)) | |
| .addModifiers(PRIVATE, STATIC, FINAL) | |
| .addField(instanceHolderFieldBuilder.build()) | |
| .build(); | |
| } |
Metadata
Metadata
Assignees
Labels
No labels