Clojure

add annotation support to gen-class

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.2
  • Component/s: None
  • Labels:
    None
  • Approval:
    Ok

Description

Just call the same code used by definterface/type/record

Activity

Hide
Assembla Importer added a comment -

dsg said: Here is my implementation of annotations for gen-class. At present, it only adds annotations to the class, declared (not inherited) methods, and parameters in declared methods. The syntax mimics the syntax from deftype and is viewable in test/clojure/test_clojure/genclass/examples.clj.

Show
Assembla Importer added a comment - dsg said: Here is my implementation of annotations for gen-class. At present, it only adds annotations to the class, declared (not inherited) methods, and parameters in declared methods. The syntax mimics the syntax from deftype and is viewable in test/clojure/test_clojure/genclass/examples.clj.
Hide
Assembla Importer added a comment -

dsg said: [file:bK_ToyuHSr36E9eJe5cbLA]: Patch that adds annotation support to gen-class.

Show
Assembla Importer added a comment - dsg said: [file:bK_ToyuHSr36E9eJe5cbLA]: Patch that adds annotation support to gen-class.
Hide
Assembla Importer added a comment -

stu said: Hi Daniel,

I found out the hard way that using a decent sample of annotation classes in the tests will break the official build (which has to run on Java 1.5). I finessed this issue by splitting the tests into separate Java 1.5 and Java 1.6 files, you can see this in clojure/test_clojure/annotations.clj

This patch will need something similar. Do you have time to get to it in the next few days?

Stu

Show
Assembla Importer added a comment - stu said: Hi Daniel, I found out the hard way that using a decent sample of annotation classes in the tests will break the official build (which has to run on Java 1.5). I finessed this issue by splitting the tests into separate Java 1.5 and Java 1.6 files, you can see this in clojure/test_clojure/annotations.clj This patch will need something similar. Do you have time to get to it in the next few days? Stu
Hide
Assembla Importer added a comment -

dsg said: Hello, Stu,

Yes, I noticed your other updates to the other bug, but haven't taken the time to look at it in detail, yet. I will make some time to fix this in the next day or two.

Sincerely,

Daniel Solano G��mez

Show
Assembla Importer added a comment - dsg said: Hello, Stu, Yes, I noticed your other updates to the other bug, but haven't taken the time to look at it in detail, yet. I will make some time to fix this in the next day or two. Sincerely, Daniel Solano G��mez
Hide
Assembla Importer added a comment -

dsg said: Unfortunately, since gen-class depends on AOT compilation, fixing the Java 5 issue is not as simple for gen-class as it is for deftype. Most solutions will require changes to the build script. Here are my proposed solutions:

Option 1: Disable tests for Java 5

Simply don't try to compile the test class and skip the annotation tests if the VM is version 5. Given that Java 5 from Oracle has reached its end of life, this option has the appeal of simplicity.

Option 2: The deftype approach

Like deftype, create a simplified set of tests for Java 5. The build script will have to conditionally compile either a Java 5 test class or a Java 6+ test class.

Option 3: Custom annotations

Write a custom set of annotations (probably in Java). This way the tests will not be dependent on which JVM version is being used. This would keep the test code itself simple, and could be reused by the deftype tests.

Option 4: Restricted annotations

Restrict the annotations used to those available in Java 5. Unfortunately, there are not many, and I don't think that any of them allow features like nested annotations. I could be mistaken, though.

I appreciate any opinion on what is the preferred way to handle this problem.

Show
Assembla Importer added a comment - dsg said: Unfortunately, since gen-class depends on AOT compilation, fixing the Java 5 issue is not as simple for gen-class as it is for deftype. Most solutions will require changes to the build script. Here are my proposed solutions: Option 1: Disable tests for Java 5 Simply don't try to compile the test class and skip the annotation tests if the VM is version 5. Given that Java 5 from Oracle has reached its end of life, this option has the appeal of simplicity. Option 2: The deftype approach Like deftype, create a simplified set of tests for Java 5. The build script will have to conditionally compile either a Java 5 test class or a Java 6+ test class. Option 3: Custom annotations Write a custom set of annotations (probably in Java). This way the tests will not be dependent on which JVM version is being used. This would keep the test code itself simple, and could be reused by the deftype tests. Option 4: Restricted annotations Restrict the annotations used to those available in Java 5. Unfortunately, there are not many, and I don't think that any of them allow features like nested annotations. I could be mistaken, though. I appreciate any opinion on what is the preferred way to handle this problem.
Hide
Assembla Importer added a comment -

stu said: The official build of Clojure is still Java 5, so let's do Option 4 for now. If we ever get burned by it, we'll create a ticket for options 3.

Show
Assembla Importer added a comment - stu said: The official build of Clojure is still Java 5, so let's do Option 4 for now. If we ever get burned by it, we'll create a ticket for options 3.
Hide
Assembla Importer added a comment -

dsg said: OK, no problem. I will try to see if it's possible to do some things like nesting with the Java 5 annotation set. The annotations may not be semantically sound, but they may work nonetheless. Off-hand, it seems like many restrictions are enforced only at compile time.

I will submit an updated patch later this afternoon.

Show
Assembla Importer added a comment - dsg said: OK, no problem. I will try to see if it's possible to do some things like nesting with the Java 5 annotation set. The annotations may not be semantically sound, but they may work nonetheless. Off-hand, it seems like many restrictions are enforced only at compile time. I will submit an updated patch later this afternoon.
Hide
Assembla Importer added a comment -

dsg said: [file:b1J4pcwjqr35cDeJe5cbCb]: New patch, Java 5 compatible.

Show
Assembla Importer added a comment - dsg said: [file:b1J4pcwjqr35cDeJe5cbCb]: New patch, Java 5 compatible.
Hide
Assembla Importer added a comment -

dsg said: Updated patch, tested with both Sun JDK 1.5.0.22 and 1.6.0.20 on Linux.

Show
Assembla Importer added a comment - dsg said: Updated patch, tested with both Sun JDK 1.5.0.22 and 1.6.0.20 on Linux.
Hide
Assembla Importer added a comment -

importer said: (In [[r:8b1ea574a61b105b9cbe9ffa3b05785cec0b3bc0]]) Add annotations support to gen-class, plus tests. See #318.

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>

Branch: master

Show
Assembla Importer added a comment - importer said: (In [[r:8b1ea574a61b105b9cbe9ffa3b05785cec0b3bc0]]) Add annotations support to gen-class, plus tests. See #318. Signed-off-by: Stuart Halloway <stu@thinkrelevance.com> Branch: master
Hide
Assembla Importer added a comment -

stu said: Updating tickets (#310, #318, #341)

Show
Assembla Importer added a comment - stu said: Updating tickets (#310, #318, #341)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: