-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@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? |
@rharter I've seen crashes during tests on Travis CI with OpenJDK 7 too: https://travis-ci.org/tbroyer/gradle-errorprone-plugin/builds/99365020 |
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) |
Note - we're having this issue on Truth now too. |
@rharter - I believe warnings are in, or about to be in Compile-Testing, and i'll sync it out soon. |
@cgruber Great, I'll look into adding warning tests once that's done. |
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). |
@cgruber Did this ever get merged? I don't see anything in the |
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. :/ |
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. |
That sounds great. Thanks! |
@cgruber I don't think this change has been pulled in to the Google version. |
@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. |
@cgruber Any update on this? ^^ |
@rharter Looks like compile-testing 0.9 is out |
nice, I'll get this updated. |
I've tried updating the tests to use the new I think this means that the current negative test, checking that the compilation fails for unconsumed properties will have to suffice. |
If you know that there will always be this one warning, could you use Alternatively we could have a test-only way of invoking AutoValue that causes it to return true instead of false from the |
Ahh, didn't realize that that was added too, I'll look into that. |
Is it possible to pass |
@eamonnmcmanus I believe this is ready to go, now. |
I would LOVE to see this in! |
.processedWith(new AutoValueProcessor(ImmutableList.of(new FooExtension()))) | ||
.compilesWithoutError() | ||
// expected warnings: @AutoValue and @Generated annotations not consumed | ||
.withWarningCount(2); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 |
Would be good to have this merged. |
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. |
…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
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.