Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves method verification after extensions have had the chance to consume properties. #299

Closed
wants to merge 4 commits into from

Conversation

rharter
Copy link
Contributor

@rharter rharter commented Dec 30, 2015

Since compile-testing doesn't support checking warnings, I've simply tested for the inverse here, ensuring that invalid properties fail with the appropriate error. This move should also remove the warning for "abstract methods other than property getters and builder converters" for consumed methods.

@rharter
Copy link
Contributor Author

rharter commented Dec 30, 2015

@eamonnmcmanus This is failing the build on OpenJDK in some unrelated tests, with a buffer overflow in libnet.so. Any idea what that's all about?

@tbroyer
Copy link
Contributor

tbroyer commented Dec 30, 2015

@rharter I've seen crashes during tests on Travis CI with OpenJDK 7 too: https://travis-ci.org/tbroyer/gradle-errorprone-plugin/builds/99365020
Switched from the "legacy precise" to the container-based infra and it went back to green: https://travis-ci.org/tbroyer/gradle-errorprone-plugin/builds/99366548

@cgruber
Copy link
Contributor

cgruber commented Jan 10, 2016

We have some confirmation that this is a bug in the JDK which was fixed in 8 and backported to Oracle's JDK7, but not into OpenJDK7. I'm looking at a different way to fix this, as a different htmlunit runstyle could override things, but that would involve a new custom library just to run gwt tests via htmlunit on OpenJDK7, and given the real-world prevalence of 8, the non-crashiness of Oracle's jdk 7, and the container workaround I think I'm split between pushing for container use on Travis, or just dropping OpenJDK7 from the test rig (or disabling gwt tests on that jvm)

@cgruber
Copy link
Contributor

cgruber commented Jan 10, 2016

Note - we're having this issue on Truth now too.

@cgruber
Copy link
Contributor

cgruber commented Jan 10, 2016

@rharter - I believe warnings are in, or about to be in Compile-Testing, and i'll sync it out soon.

@rharter
Copy link
Contributor Author

rharter commented Jan 10, 2016

@cgruber Great, I'll look into adding warning tests once that's done.

@cgruber
Copy link
Contributor

cgruber commented Jan 10, 2016

Crap... I found that that change (warnings API on compile-testing) is still pending... but "real soon now" (next day or two, just resolving some final review issues).

@rharter
Copy link
Contributor Author

rharter commented Feb 16, 2016

@cgruber Did this ever get merged? I don't see anything in the JavaSourcesSubject that would indicate warning validation.

@cgruber
Copy link
Contributor

cgruber commented Feb 17, 2016

Hmm. I was under the impression that it had, and that we'd synced out more recently than it seems we have... I know it went in internally, but apparently we're behind on syncing out. Let me check on what's going on. :/

@cgruber
Copy link
Contributor

cgruber commented Feb 17, 2016

Yep. Sorry, it needs a sync, and I'll make sure we get a SNAPSHOT out shortly (this week), and probably a stable minor release soon after.

@rharter
Copy link
Contributor Author

rharter commented Feb 17, 2016

That sounds great. Thanks!

@eamonnmcmanus
Copy link
Member

@cgruber I don't think this change has been pulled in to the Google version.

@rharter
Copy link
Contributor Author

rharter commented Feb 29, 2016

@cgruber It looks like the changes have been merged into compile testing. Do you currently have a plan for a new maven release? I can't use this it here until you release it.

@rharter
Copy link
Contributor Author

rharter commented Mar 7, 2016

@cgruber Any update on this? ^^

@JakeWharton
Copy link
Contributor

@rharter Looks like compile-testing 0.9 is out

@rharter
Copy link
Contributor Author

rharter commented Mar 9, 2016

nice, I'll get this updated.

@rharter
Copy link
Contributor Author

rharter commented Mar 10, 2016

I've tried updating the tests to use the new compilesWithoutWarnings() method from compile-testing, but we actually always compile with at least one warning, No processor claimed any of these annotations: com.google.auto.value.AutoValue. This is apparently intentional as documented in the code. The compilesWithoutWarnings method doesn't allow me to access the actual warnings to filter out known, expected warnings, so I can't filter out that warning and ensure it doesn't contain extra warnings.

I think this means that the current negative test, checking that the compilation fails for unconsumed properties will have to suffice.

@eamonnmcmanus
Copy link
Member

If you know that there will always be this one warning, could you use withWarningCount(1)?

Alternatively we could have a test-only way of invoking AutoValue that causes it to return true instead of false from the process method.

@rharter
Copy link
Contributor Author

rharter commented Mar 11, 2016

Ahh, didn't realize that that was added too, I'll look into that.

@tbroyer
Copy link
Contributor

tbroyer commented Mar 11, 2016

Is it possible to pass -Xlint:-processing? That would remove that warning.

@rharter
Copy link
Contributor Author

rharter commented Mar 11, 2016

@eamonnmcmanus I believe this is ready to go, now.

@menny
Copy link

menny commented Mar 28, 2016

I would LOVE to see this in!
Our project has -Werror compiler flag, and without this PR in, we can not use AutoValue (and auto-value-parcel) in our source code.

.processedWith(new AutoValueProcessor(ImmutableList.of(new FooExtension())))
.compilesWithoutError()
// expected warnings: @AutoValue and @Generated annotations not consumed
.withWarningCount(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had success passing .withCompilerOptions("-Xlint:-processing") to turn off the warnings about @AutoValue and @Generated not being consumed by any processor. However, when I do that in this test, it passes without any other changes to the code. I think we need a test that fails before the rest of the modifications in this PR are made and passes afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect that would pass since you're suppressing all processor warnings. The point of this test is to ensure that those two expected warnings, and no others, are thrown. In the error case, a warning is thrown for every property, but .withCompilerOptions("-Xlint:-processing") would suppress those.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, no, -Xlint:-processing is only about the warning wrt annotations that haven't been claimed by a processor (and most processors, including Auto ones, don't claim annotations at all).
https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#xlintwarnings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, yes, good point. My misunderstanding.

@@ -18,7 +18,8 @@
*
* <p>Extensions can extend the AutoValue implementation by generating subclasses of the AutoValue
* generated class. It is not guaranteed that an Extension's generated class will be the final
* class in the inheritance hierarchy, unless its {@link #mustBeFinal(Context)} method returns true.
* class in the inheritance hierarchy, unless its
* {@link com.google.auto.value.extension.AutoValueExtension#mustBeFinal(Context)} method returns true.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing the purpose of these {@link} rewrites. The previous versions work for me. Is there a context where they don't?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure why those got in there. Works fine for me, too. I've reverted them.

@eamonnmcmanus
Copy link
Member

Sorry about the delay in getting to this. I've pulled it into our local repository but before committing it I want to restructure the code somewhat. The AutoValueProcessor.processType method in particular is getting a bit unwieldy. I'd also like to get rid of the warning for abstract methods like writeToParcel(Parcel, int), which implies generalizing the support for consuming properties so that you can also consume other abstract methods.

@Rainer-Lang
Copy link

Would be good to have this merged.

@eamonnmcmanus
Copy link
Member

I'm going to close this PR because our processes mean that we incorporate changes internally at Google rather than on github. I've made a chunk of changes to extensions, partly based on this PR, which will appear at our next push.

eamonnmcmanus added a commit to eamonnmcmanus/auto that referenced this pull request May 10, 2016
…his involves moving a fair amount of code around, but the resultant organization for method identification should be clearer. The principal purpose of the restructuring is to get rid of warnings about abstract methods when those methods are going to be implemented by an extension. A second purpose is to fix a bug where extensions would not work right if there was a toBuilder() method.

Also improve the test coverage in ExtensionTest, which was fairly minimal.

Some of the code in this change is based on google#299 by @rharter.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120485500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants