-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
None
-
generic
-
generic
Problem description:
====================
The javadoc for constructor of the javax.smartcardio.CardTerminal class
states as follows:
---Excerpt-from-spec---
protected CardTerminal(TerminalFactory factory)
Constructs a new CardTerminal object.
This constructor is called by subclasses only. Application should call terminals() or getTerminal() to obtain a CardTerminal object.
Parameters:
factory - the TerminalFactory that created this terminal
Throws:
NullPointerException - if factory is null
---End-of-Excerpt-from-spec---
However, NullPointerException is not thrown if factory is null.
Please run the minimized test to reproduce failure.
Minimized test:
===============
--- test.java ---
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
public class test {
public static void main(String[] args) {
try {
CardTerminal term = new StubCardTerminal((TerminalFactory)null);
System.out.println("Failed. NullPointerException was not thrown.");
} catch (NullPointerException e) {
System.out.println("Passed.");
}
}
}
--- test.java ---
--- StubCardTerminal.java ---
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
public class StubCardTerminal extends CardTerminal {
public StubCardTerminal(TerminalFactory factory) {
super(factory);
}
public String getName() {
return "JCKCardTerminal";
}
public Card connect(String protocol) throws CardException {
return null;
}
public boolean isCardPresent() throws CardException {
return false;
}
public boolean waitForCardPresent(long timeout) throws CardException{
return false;
}
public boolean waitForCardAbsent(long timeout) throws CardException {
return true;
}
}
--- StubCardTerminal.java ---
Minimized test output:
======================
[vs158239@vsmelov CardTerminal]$ javac *.java
[vs158239@vsmelov CardTerminal]$ java -cp ./ test
Failed. NullPointerException was not thrown.
[vs158239@vsmelov CardTerminal]$ java -version
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b84)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b84, mixed mode)
====================
The javadoc for constructor of the javax.smartcardio.CardTerminal class
states as follows:
---Excerpt-from-spec---
protected CardTerminal(TerminalFactory factory)
Constructs a new CardTerminal object.
This constructor is called by subclasses only. Application should call terminals() or getTerminal() to obtain a CardTerminal object.
Parameters:
factory - the TerminalFactory that created this terminal
Throws:
NullPointerException - if factory is null
---End-of-Excerpt-from-spec---
However, NullPointerException is not thrown if factory is null.
Please run the minimized test to reproduce failure.
Minimized test:
===============
--- test.java ---
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
public class test {
public static void main(String[] args) {
try {
CardTerminal term = new StubCardTerminal((TerminalFactory)null);
System.out.println("Failed. NullPointerException was not thrown.");
} catch (NullPointerException e) {
System.out.println("Passed.");
}
}
}
--- test.java ---
--- StubCardTerminal.java ---
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
public class StubCardTerminal extends CardTerminal {
public StubCardTerminal(TerminalFactory factory) {
super(factory);
}
public String getName() {
return "JCKCardTerminal";
}
public Card connect(String protocol) throws CardException {
return null;
}
public boolean isCardPresent() throws CardException {
return false;
}
public boolean waitForCardPresent(long timeout) throws CardException{
return false;
}
public boolean waitForCardAbsent(long timeout) throws CardException {
return true;
}
}
--- StubCardTerminal.java ---
Minimized test output:
======================
[vs158239@vsmelov CardTerminal]$ javac *.java
[vs158239@vsmelov CardTerminal]$ java -cp ./ test
Failed. NullPointerException was not thrown.
[vs158239@vsmelov CardTerminal]$ java -version
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b84)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b84, mixed mode)
- duplicates
-
JDK-6417746 (smartcardio) TerminalFactory.waitForCardPresent methods does not throw IllegallArgumentException
-
- Closed
-
- relates to
-
JDK-6425901 (smartcardio) RI's implementation of CardTerminal.getTerminalFactory() return null
-
- Closed
-