Fix several JDT-related problems

This PR combines fixes for the problems that I encountered today while trying out the current state on master in some larger Eclipse projects, using JDT as processor environment.

I hope it's ok to put the commits into one PR. The first commit extends an existing integration test with some generics and ```@TargetType``` stuff. It should fail for the test cases that use JDT.

The following commits step-by-step fix the problems that I encountered (applicable individually), leading to a fixed integration test in the end.

The fixes are for #312, #344, #345.