Can't open declaration of class in Eclipse [message #1713833] |
Fri, 06 November 2015 19:08 |
Nicholas Duane Messages: 2 Registered: November 2015 |
Junior Member |
|
|
I posted this to stackoverflow yesterday and thought it might be a good idea to post here also. Since this is my first post I can't include the link to it. The title of that post is the same as this one.
I'm new to java and linux. I'm running fedora 21 and have installed the most recent open-jdk. I also just installed eclipse and the JAD eclipse plug-in so that I can view the decompiled source of framework classes.
I've written my own socket class, UnixSocket.java, which extends java.net.Socket. When I open my UnixSocket.java file in eclipse I can right mouse on java.net.Socket which I'm extending and choose "Open Declaration" and the source of the java.net.Socket class will appear in the right pane. However, when I open my class which extends java.nio.channels.SocketChannel, UnixSocketChannel.java, and right mouse on java.nio.channels.SocketChannel and choose "Open Declaration" I get an error which says:
"The resource is not on the build path of a java project."
I've searched around and found some other posts regarding this error, I can't include the link to one of those either. The title of one, which is also on stackoverflow, is:
Understanding Eclipses' "The resource is not on the build path of a Java project" error message?
But unfortunately it didn't help me out.
In addition, the error is intermittent, or at least it can come and go probably based on what steps I have taken. I was able to view the source of the SocketChannel class one time. But then I couldn't get the source for the Socket class. One of the times I couldn't get the source for either the Socket class or the SocketChannel class.
I haven't set my CLASSPATH so it should be set to whatever eclipse initializes it to. In eclipse it says the CLASSPATH is:
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.60-14.b27.fc21.x86_64/jre/lib/rt.jar
Anyone have any idea why this feature works sometimes and doesn't work sometimes?
Below are my two of my source files. They both compile without errors. They depend on some other classes of mine which I have not included.
// UnixSocket.java
package unixsockets;
import java.net.Socket;
import java.nio.channels.SocketChannel;
import java.net.SocketException;
public class UnixSocket extends Socket
{
private SocketChannel _channel;
public UnixSocket(SocketChannel channel)
throws SocketException
{
super(new UnixSocketImpl());
this._channel = channel;
}
@Override
public SocketChannel getChannel()
{
return this._channel;
}
}
// UnixSocketChannel.java
package unixsockets;
import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.spi.SelectorProvider;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.io.IOException;
import java.net.SocketException;
import java.net.SocketOption;
import java.net.SocketAddress;
import java.util.Set;
public class UnixSocketChannel extends SocketChannel
{
private Socket _socket;
protected UnixSocketChannel(SelectorProvider selectorProvider)
throws SocketException
{
super(selectorProvider);
this._socket = new UnixSocket(this);
}
// SocketChannel
public SocketChannel bind(SocketAddress address)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public boolean connect(SocketAddress address)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public boolean finishConnect()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public SocketAddress getRemoteAddress()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public boolean isConnected()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public boolean isConnectionPending()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public static SocketChannel open() throws IOException
{
return new UnixSocketChannel(SelectorProvider.provider());
}
public static SocketChannel open(SocketAddress address)
throws IOException
{
SocketChannel channel = open();
channel.socket().connect(address);
return channel;
/*
UnixSocketChannel channel = new UnixSocketChannel(
SelectorProvider.provider());
return new UnixSocket(address).channel();
*/
}
public int read(ByteBuffer dst)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public long read(ByteBuffer[] dsts, int offset, int length)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public <T> SocketChannel setOption(SocketOption<T> name, T value)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public SocketChannel shutdownInput()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public SocketChannel shutdownOutput()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
@Override
public Socket socket()
{
return this._socket;
}
public int write(ByteBuffer src)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public long write(ByteBuffer[] srcs, int offset, int length)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
// AbstractSelectableChannel
protected void implCloseSelectableChannel()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
protected void implConfigureBlocking(boolean block)
{
Native.setNonBlocking(0, true);
// throw(new UnsupportedOperationException("Not yet implemented"));
}
// NetworkChannel
public SocketAddress getLocalAddress()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public <T> T getOption(SocketOption<T> name)
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
public Set<SocketOption<?>> supportedOptions()
{
throw(new UnsupportedOperationException("Not yet implemented"));
}
}
Thanks,
Nick
|
|
|
|
Powered by
FUDForum. Page generated in 0.07929 seconds