Menu

#184 unable to access protected vars from Java class

open
nobody
None
5
2006-10-18
2006-10-18
Isaac Gouy
No

Defined Nice class that extends BufferedInputStream,
but unable to access protected variables defined in
BufferedInputStream from the Nice class.

No problems with this Java

import java.io.*;

public class TestOne extends BufferedInputStream {

public TestOne(InputStream in){ super(in); }

int testmarkpos(){ return markpos; }

public static void main(String[] args) {
System.out.println( (new
TestOne(System.in)).testmarkpos() );
}
}

Problems with this Nice

import java.io.*;

class TestTwo extends BufferedInputStream {

int testmarkpos(){ return markpos; }

void main(String[] args) {
println( (new TestTwo(System.in)).testmarkpos() );
}
}

$ /opt/nice-0.9.12/bin/nicec -d . --sourcepath .. -a
t.jar TestTwo
nice.lang: parsing
TestTwo: parsing

~/tmp/TestTwo/TestTwo.nice: line 5, column 36:
markpos is not declared
compilation failed with 1 error

Discussion


Log in to post a comment.

Auth0 Logo