-1

See my blog post for excerpt from Java Posse #386 - Newscast for May 31st 2012 that expands this topic.

Does JSR 308 promotes design-by-contract to Java? It is step further from assertions? When it will be part of JDK?

When it is scheduled to be released as part of JDK?

See also Do you use assertions?

Community
  • 1
  • 1
alexsmail
  • 5,661
  • 7
  • 37
  • 57
  • 2
    How would we know when it'll be in the JDK? It's "scheduled" for JDK 8 or later. If ever. But no, 308 is an enhancement to *where* annotations can appear. It may *help* in DbC™ implementations, but in itself isn't related. If anywhere, this should be on http://programmers.stackexchange.com. – Dave Newton Jun 16 '12 at 14:48
  • Why programmers? See the addition above. – alexsmail Jun 16 '12 at 14:50
  • It's not a specific question (in addition to the OT parts). I didn't downvote, but I did vote to close as OT. – Dave Newton Jun 16 '12 at 14:51
  • I think you're confused on what 308 is. 308 extends **where** annotations can be used. It doesn't have any annotations on its own. As such, it has nothing to do with assertions, DbC™, etc. It may be **used** to implement arbitrary functionality. – Dave Newton Jun 16 '12 at 14:59
  • The Checker Framework:Custom pluggable types for Java Nullness checker http://types.cs.washington.edu/checker-framework/current/checkers-manual.html#nullness-checker This link I found from JSR 308 page. – alexsmail Jun 16 '12 at 15:00
  • Checker is a tool that uses 308 functionality. To quote from [your link](http://types.cs.washington.edu/jsr308/): "[JSR-308] describes the minor, backward-compatible changes to the Java language and classfile format." It also says "and ***then*** tools such as type-checkers can detect and prevent more errors." Checker is one of those tools. It **uses** 308. – Dave Newton Jun 16 '12 at 15:04
  • Thanks for clarification. But for now, neither JSR-308, not type-checkers (that can be expanded for design by contract) is not part of JDK. – alexsmail Jun 16 '12 at 15:11
  • Yes, we're aware of that. Doesn't mean you can't use it. – Dave Newton Jun 16 '12 at 15:14

1 Answers1

3

JSR 308 is not related to contracts. Instead, it extends the Java type system so that you can modify basic types depending on their usage context. The Checker Framework gives a few great examples of what can be done with type annotations. I'm sure you can somehow subvert this to turn it into contracts, but you'd still have to add a custom processor that compiles annotations into code rather than just passing them through a type checker.

And currently the plan is to include in the Java 8. But that can still change.

mernst
  • 7,437
  • 30
  • 45
Jochen
  • 2,277
  • 15
  • 22