如何融合两个java开源项目

halllv 2007-10-30 09:01:06
一个开源项目bamboo,用了一个Oceanstore项目的类生产了jar作为lib,现在我需要修改oceanstore里面的类来使得bamboo支持ipv6,在原来jar文件里面,Nodeid,相关的类包含了四个class文件::NodeId$1.class, NodeId$BadFormat.class, NodeId$Both.class,NodeId.class文件,而我现在下来Oceanstore源码,修改后编译只有两个calss文件,NodeId$BadFormat.class,NodeId.class。我用这两个文件运行jar -uf 更新jar里面的这两个文件,在运行bamboo程序就出了错误。。
我的问题是:
NodeId$1.class和odeId$Both.class是什么意思,编译源代码为什么没有两个文件产成,
而且我这种直接更新jar文件,是因为其他两个nodeid类文件的.class没有更新出现的问题,还是其他原因使得运行发生错误
在bamboo的lib里面有makefile文件,是不是更新里面的lib要使用make命令呢,为什么我使用是提示 Nothing to be done for `all'

我该怎么去融合两个开源项目呢,重新编写makefile有太麻烦,这么直接更新又出现错误。

下面是NodeId.java 文件和lib里面的makefile文件

package ostore.util;
import java.io.*;
import java.net.*;

public class NodeId implements QuickSerializable, Comparable, Cloneable {

public static final boolean DEBUG = ostore.util.DebugFlags.NODEID;

public class BadFormat extends Exception {
public BadFormat (String msg) {
super (msg);
}

public String toString () {
return "BadFormat: " + getMessage ();
}
}

/**
* Construct a new NodeId.
*
* @param port The network port; must be between 0 and 65535 inclusive.
* @param addr The IP address
*/
public NodeId (int port, InetAddress addr) {
_addr = addr;
_port = port;

}

/**
* Read this NodeId in from a string of the same format as produced by
* toString (), below.
*/
public NodeId (String peer) throws BadFormat, UnknownHostException {


int colon = peer.indexOf ((int) ':');
if (colon < 0)
throw new BadFormat (peer);
String ip_str = peer.substring (0, colon);
String port_str = peer.substring (colon+1, peer.length ());
_port = Integer.parseInt (port_str);
// try to parse out the ip bytes first, then go with a resolve
// operation if that doesn't work

_ip_bytes = new byte [4];
String munch = ip_str;
int b = 0;
for ( ; b < 4; ++b) {
int dot = munch.indexOf ((int) '.');
if (dot == -1) break;
String this_byte = munch.substring (0, dot);
try {
_ip_bytes [b] = Byte.parseByte (this_byte);
}
catch (NumberFormatException e) {
break;
}
munch = munch.substring (dot+1, munch.length ());
}

if (b != 4) {
_ip_bytes = null;
_addr = InetAddress.getByName (ip_str);
}

if( DEBUG ) {
if( _port > 10000 ) {
Debug.printtagln( "NodeId.init", _addr +
" has a big port: " + _port );
}
}
}

public NodeId () { }



public void serialize (OutputBuffer buffer)
{
if (_ip_bytes == null)
_ip_bytes = _addr.getAddress ();
buffer.add((short) _port);
buffer.add((byte) _ip_bytes.length);
buffer.add(_ip_bytes);
}

public NodeId (InputBuffer buffer) throws QSException {
_port = 0xFFFF & (int) buffer.nextShort ();
int length = (int) buffer.nextByte ();
if (length > 16) // big enough for IPv4 and IPv6
throw new QSException ("IP addr len = " + length);
_ip_bytes = new byte [length];
buffer.nextBytes (_ip_bytes, 0, length);
_addr = null;
}

/**
* Return the InetAddress associated with this NodeId; does not work
* under the simulator.
*
* <p><b>JUST TO MAKE THAT CLEAR, THIS FUNCTION WILL NOT WORK IN THE
* OCEANSTORE SIMULATOR. YOU HAVE BEEN WARNED.</b>
*/
public InetAddress address () {
if (_addr == null) {
String addr = "";
for (int i = 0; i < _ip_bytes.length; ++i) {
long value = ByteUtils.byteToUnsignedInt (_ip_bytes [i]);
addr += value;
if ((i + 1 ) != _ip_bytes.length)
addr += ".";
}
try {
_addr = InetAddress.getByName (addr);
}
catch (UnknownHostException e) {
if (DEBUG) Debug.printtagln ("NodeId.address",
"Could not construct an InetAddress from " + addr
+ ": Unknown host exception.");
return null;
}
}
return _addr;
}

public int port () {
return _port;
}

public String toString () {
// Do not change this format. It was chosen specifically to be
// compatible with Steve Gribble's networking code.
return address ().getHostAddress () + ":" + _port;
}

/**
* Specified by the <code>Comparable</code> interface.
*/
public int compareTo (Object other) {

if( equals(other) ) {
return 0;
} else if( less_than( (NodeId) other) ) {
return -1;
} else {
return 1;
}

}

public boolean equals (Object other) {
if (other == null)
return false;
NodeId rhs = (NodeId) other;
if (_port != rhs._port)
return false;
return address ().equals (rhs.address ());
}

/**
* <code>a.less_than (b)</code> returns true iff <code>a</code> is less
* than <code>b</code>. Used for sorting <code>NodeId</code>s.
*/
public boolean less_than (NodeId other) {
if (_ip_bytes == null)
{
_ip_bytes = _addr.getAddress ();
if (_ip_bytes == null) {
Carp.die ("_ip_bytes == null, _addr = " + _addr +
". This usually happens because you're running " +
"with Java 1.4 under SandStorm (NBIO, to be exact)."+
" Make sure you're running with Java 1.3, and it " +
"should go away.");
}
}
if (other._ip_bytes == null)
other._ip_bytes = other._addr.getAddress ();
for (int i = 0; i < _ip_bytes.length; ++i) {
if (_ip_bytes [i] < other._ip_bytes [i])
return true;
else if (_ip_bytes [i] > other._ip_bytes [i])
return false;
}
// addresses are equal, compare ports
return _port < other._port;
}

public int hashCode() {
if (_ip_bytes == null)
{
_ip_bytes = _addr.getAddress ();
if (_ip_bytes == null) {
Carp.die ("_ip_bytes == null, _addr = " + _addr +
". This usually happens because you're running " +
"with Java 1.4 under SandStorm (NBIO, to be exact)."+
" Make sure you're running with Java 1.3, and it " +
"should go away.");
}
}
int result = 0;
for (int i = 0; i < _ip_bytes.length; ++i) {
result <<= 8;
result |= (_ip_bytes [i] >= 0) ? _ip_bytes [i]
: (_ip_bytes [i] * -1);
}
result ^= _port;
return result;
}

/**
* Create an exact copy of this <CODE>NodeId</CODE>
* @return new <CODE>NodeId</CODE> identical in value to this one
* @exception CloneNotSupportedException if clone() is not supported */
public Object clone() throws CloneNotSupportedException
{
return new NodeId(port(), address());
}

private byte _ip_bytes[];
private InetAddress _addr;
private int _port;
}


Makefile文件

BAMBOO_HOME = ../
include ../src/bamboo/Makefile.include

JAR_FILES = \
#省略了其他.class文件

-C ~/oceanstore/pond ostore/util/NodeId\$$BadFormat.class \
-C ~/oceanstore/pond ostore/util/NodeId.class \
-C ~/oceanstore/pond ostore/util/NonceAckMsg.class \

#省略其他.class文件

all:

ostore-seda-emu.jar:
rm -f $@
$(JAVAHOME)/bin/jar cf $@ $(JAR_FILES)
...全文
180 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lilifb 2007-11-17
  • 打赏
  • 举报
回复
mark
胡矣 2007-11-15
  • 打赏
  • 举报
回复
把要调用类的JAR包直接导入进来?
weijiepeng 2007-11-14
  • 打赏
  • 举报
回复
mark
manbaum 2007-10-30
  • 打赏
  • 举报
回复
NodeId$1.class, NodeId$BadFormat.class, NodeId$Both.class,NodeId.class
名字里有$的是内部类,也就是包含在NodeId中的。你改的类里没有这些内部类,当然就不生成了。

你的代码太乱了,我是没兴趣看。csdn提供了java的语法着色,为什么不用呢??

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧