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

make code compiles with jdk 6 #64

Merged
merged 1 commit into from
Oct 27, 2014
Merged

make code compiles with jdk 6 #64

merged 1 commit into from
Oct 27, 2014

Conversation

swolf91
Copy link
Contributor

@swolf91 swolf91 commented Oct 14, 2014

This pull request closes #58 it changes the code so that it compiles with jdk 6 instead of 7.

@swolf91
Copy link
Contributor Author

swolf91 commented Oct 15, 2014

It compiles with the jdk 1.6 and every test passes. The test needs still the jdk 7.

For now I removed the usage of the AutoCloseable interface. The documentations tells the user that it'a a resource from the try as resource functionality. So it should be clear. What do you think about that?

@@ -162,7 +162,7 @@ public A getActualAnnotation() {
}

@SuppressWarnings("unchecked")
private <E extends Enum<E>> Object convertValue(Object value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you remove this generic method type ?

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 removed it because I got errors with that generic method type. Every time the convert value was invoked was the following message:

"incompatible types; inferred type argument(s) java.lang.Object do not conform to bounds of type variable(s) E
[ERROR] found : java.lang.Object
[ERROR] required: java.lang.Object"

I solved it within the convertValue method by invoking the method this way:

this.<E>convertValue(field.getDefaultExpression());

But I didn't find a way to solve it within the method getElementValue(String). Do you have any suggestions for solving that?

By the way it seems to work for you because you compile the project with the jdk 7, right? The error just appears while compiling it with the jdk 6

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, no. Java 1.6 don't seems to support generic type in methods and the only solution I have found is the same of yours.

By the way it seems to work for you because you compile the project with the jdk 7, right? The error just appears while compiling it with the jdk 6

Facepalm for me. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Facepalm for me. :)

No problem, I did that mistake several times. The tests still needs the jdk 7. So one has to validate the code with the jdk 7. But before I always try to compile it with jdk 6.
One could solve it with restructuring the tests. It's possible to have JUnit tests at the same place but move the files which are scanned by spoon into the resource folder. Maven wouldn't compile them anymore and so the scanned files could use java 7 or 8.. But the used jdk can be still 6. One could give it a try with another pull request.

@monperrus @pschichtel Do you have any suggestions to solve the generic method type thing without removing it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Java 1.6 don't seems to support generic type in methods

Java 6 does support this, the compiler is just not good when it comes to type inference, so you often have to hint the type

@GerardPaligot
Copy link
Contributor

Thanks @boeserwolf91 for this PR, that's seems nice. I pulled your branch in local and everything seems ok with me.

I just have one question (see comment on your source code) because, for me, it is compatible java 1.6 (and without the modification, the project still compiles).

For AutoCloseable, it is pity but everything works so ok for me.

@swolf91 swolf91 changed the title [WIP] make code compiles with jdk 6 make code compiles with jdk 6 Oct 15, 2014
default:
return null;
public static OutputType fromString(String string)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

At the root of this project, you can find a formatter for spoon project (https://github.com/INRIA/spoon/blob/master/SpoonFormatterPrefs.xml). If everyone use his own formatter, source code will quickly become unreadable.

Can you use it ? Or put braces at the end of the signature of the method ?

Thanks in advance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Unfortunately" (I hate eclipse) I can't use this file because I don't use eclipse. But I'll format it like you did. Give me a second

Copy link
Contributor

Choose a reason for hiding this comment

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

I hate Eclipse too and latest versions of IntelliJ support formatters of Eclipse (if you use IntelliJ of course). :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really IntelliJ supports that? Good to know. Thank you 👍

@monperrus
Copy link
Collaborator

We are about to accept this PR. However, note that as soon as full support of analysis and transformation of Java 7 is added, we'll probably add a dependency to Java 7 again.

@pschichtel
Copy link
Contributor

why is that @monperrus ?

@swolf91
Copy link
Contributor Author

swolf91 commented Oct 20, 2014

Does the transformation need Java 7? I think the analysis doesn't need it.

@monperrus
Copy link
Collaborator

Does the transformation need Java 7? I think the analysis doesn't need it.

We'll see. My point is that this pull request may be short-lived if it
turns out that we absolutely need a dependency to Java 7 to fully
support analysis and transformation of Java 7.

Best regards,

--Martin

@swolf91
Copy link
Contributor Author

swolf91 commented Oct 23, 2014

I got it @monperrus
yes we'll see how long we can use java 6. But it would be nice to have it in the next release 😄

@monperrus
Copy link
Collaborator

OK, we're on the same wavelength now.
We'll merge it during next Monday's merge session.
Before that, could you squash all the commits in a single one? Thanks.

@swolf91
Copy link
Contributor Author

swolf91 commented Oct 23, 2014

Of course I could squash it. But I did several commits because every commit changes another thing. Are you really sure that I shall squash it into a single one?

@swolf91 swolf91 mentioned this pull request Oct 23, 2014
petitpre added a commit that referenced this pull request Oct 27, 2014
@petitpre petitpre merged commit a5df364 into INRIA:master Oct 27, 2014
@swolf91 swolf91 deleted the java6 branch October 27, 2014 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compile with java 1.6 or lower
5 participants