github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

adamw / jsr308-typestate-checker

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 80894c9

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

JSR308 Typestate Checker — Read more

  cancel

http://www.warski.org/typestate.html

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Fixing bugs, adding InputStream example 
adamw (author)
Tue Apr 14 09:10:24 -0700 2009
commit  80894c97ce345bf833a7df6fb9079ec66d7f0c89
tree    2788747f1b0e04a57f0582398f71915ae603ff75
parent  2193f552fa5ac47366df554d0dc0cb6601d986d9
jsr308-typestate-checker / example / src / checkers / typestate / ioexample / Example1.java example/src/checkers/typestate/ioexample/Example1.java
100644 29 lines (24 sloc) 0.612 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package checkers.typestate.ioexample;
 
import java.io.InputStream;
import java.io.IOException;
 
import static checkers.typestate.ioexample.InputStreamStates.*;
 
/**
* Cannot read from an input stream after it's closed.
* @author Adam Warski (adam at warski dot org)
*/
public class Example1 {
public int read(@Open InputStream stream) throws IOException {
int ret = 0;
try {
int input;
while ((input = stream.read()) != -1) {
ret += input;
}
} finally {
stream.close();
}
 
// This results in an error: the stream is in the "closed" state.
ret += stream.read();
 
return ret;
}
}
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server