Java - "错误:找不到符号"

时间:2016-11-08 07:47:21

标签: java compilation compiler-errors

我有一个makefile,它执行以下操作:

all:    
    CLASSPATH=$(SELF)/RT/real:$(SELF)/RT/fake:$(SELF)/RT/fake/uj javac $(SELF)/RT/real/java/lang/*.java
    CLASSPATH=$(SELF)/RT/real:$(SELF)/RT/fake:$(SELF)/RT/fake/uj javac $(DIR)/Components/UJ*.java 
    find $(SELF)/RT/real -iname "*.class" -type f >> $(SELF)/files
    find $(DIR)/Components -iname "UJCmp.class" -type f >> $(SELF)/files
    $(foreach C, $(shell echo $(CLASSES) | tr ',' ' '), \
        CLASSPATH=$(SELF)/RT/real:$(SELF)/RT/fake:$(SELF)/RT/fake/uj \
        javac $(DIR)/Components/UJ*.java $(DIR)/Components/$(C).java && \
        find $(DIR)/Components -iname "$(C).class" >> $(SELF)/files && \
    ) true
    cat $(SELF)/files | xargs $(CMD) >$(OUT)

但是在终端中产生以下输出:

make -C /home/sven/git/uJVM_PhD_Project/UPNP/micropnp-contiki/build/../../uJ//BUILDENV DIR=../../uJ CCVT=../../classCvt/classCvt TOBIN=../../classCvt/tobin CLASSES= OUTPUT=__code.c
make[1]: Entering directory '/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV'
CLASSPATH=/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV//RT/real:/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV//RT/fake:/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV//RT/fake/uj javac /home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV//RT/real/java/lang/*.java
CLASSPATH=/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV//RT/real:/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV//RT/fake:/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV//RT/fake/uj javac ../../uJ/Components/UJ*.java 
../../uJ/Components/UJCmp.java:81: error: cannot find symbol
        int L1 = res_name.Xlen_();
                         ^
  symbol:   method Xlen_()
  location: variable res_name of type String
../../uJ/Components/UJCmp.java:82: error: cannot find symbol
        int L2 = method_name.Xlen_();           
                            ^
  symbol:   method Xlen_()
  location: variable method_name of type String
../../uJ/Components/UJCmp.java:86: error: cannot find symbol
            b1[i] = ((byte)res_name.XbyteAt_(i));   
                                   ^
  symbol:   method XbyteAt_(int)
  location: variable res_name of type String
../../uJ/Components/UJCmp.java:89: error: cannot find symbol
            b2[i] = ((byte)method_name.XbyteAt_(i));    
                                      ^
  symbol:   method XbyteAt_(int)
  location: variable method_name of type String
../../uJ/Components/UJCmp.java:101: error: cannot find symbol
        int i, L = s.Xlen_();           //we cheat by not calling string methods - they are slow
                    ^
  symbol:   method Xlen_()
  location: variable s of type String
../../uJ/Components/UJCmp.java:102: error: cannot find symbol
        for(i = 0; i < L; i++) uj.lang.RT.consolePut((char)s.XbyteAt_(i));  
                                                            ^
  symbol:   method XbyteAt_(int)
  location: variable s of type String
6 errors
Makefile:49: recipe for target 'all' failed
make[1]: *** [all] Error 1
make[1]: Leaving directory '/home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV'
../../uJ/Makefile.include:93: recipe for target '__code.c' failed

奇怪的是,符号.Xlen_()和其他符号包含在&#34; / home / sven / git / uJVM_PhD_Project / UPNP / uJ / BUILDENV / RT / fake / uj / lang中的.java文件中/MiniString.java" (并且是公开的)。 因此,在尝试编译UJCmp.java时,我认为它包含在类路径中。所以我不知道它为什么会产生这个错误。

我错过了什么?

编辑:我有一个相当奇怪的设置并覆盖默认的String类。 我也会在这里发布MiniString和String的源代码:

String.java位于&#34; /home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV/RT/real/java/lang/String.java"和代码:

package java.lang;

import uj.lang。*;

public class String extends MiniString {

public String(byte[] bytes){    //our constructor for raw bytes
    super(bytes);
}

}

MiniString.java位于&#34; /home/sven/git/uJVM_PhD_Project/UPNP/uJ/BUILDENV/RT/fake/uj/lang/MiniString.java"和代码:

    package uj.lang;

public class MiniString{

    public static String Xnew_(byte[] bytes){
        return new String(bytes);
    }

    public byte XbyteAt_(int loc){
        return 0;
    }

    public int Xlen_(){ 
        return 0;
    }

    public MiniString(byte[] bytes){}

    public int length(){
        return 0;
    }

    public char charAt(int pos){
        return 0;   
    }
}

0 个答案:

没有答案
相关问题