Package xscript.runtime

Examples of xscript.runtime.XRuntimeException


    for(int i=0; i<genericInfos.length; i++){
      if(genericInfos[i].getName().equals(genericName)){
        return i;
      }
    }
    throw new XRuntimeException("Can't find generic class %s", genericName);
  }
View Full Code Here


    if(genericClass.getXClass()==this){
      return genericClass.getGeneric(genericID);
    }
    XClassTable classTable = genericClass.getXClass().getClassTable(this);
    if(classTable==null)
      throw new XRuntimeException("Can't get generic %s of class %s in class %s", "", this, genericClass);
    return classTable.getGenericPtr(genericID).getXClass(virtualMachine, genericClass, null);
  }
View Full Code Here

    if(state==STATE_CREATED){
      try{
        state = STATE_LOADING;
        String className = inputStream.readUTF();
        if(!getName().equals(className))
          throw new XRuntimeException("Wrong class name %s expect %s", getName(), className);
        modifier = inputStream.readUnsignedShort();
        if(getPackage() instanceof XClass){
          XChecks.checkModifier(this, modifier, INNERMODIFIER);
        }else if(getPackage() instanceof XMethod){
          XChecks.checkModifier(this, modifier, INNERMODIFIER);
        }else{
          XChecks.checkModifier(this, modifier, OUTERMODIFIER);
        }
        annotations = new XAnnotation[inputStream.readUnsignedByte()];
        for(int i=0; i<annotations.length; i++){
          annotations[i] = new XAnnotation(inputStream);
        }
        int childCount = inputStream.readUnsignedByte();
        for(int i=0; i<childCount; i++){
          XClass xClass = new XClass(virtualMachine, inputStream.readUTF());
          super.addChild(xClass);
          xClass.load(inputStream);
        }
        superClasses = new XClassPtr[inputStream.readUnsignedByte()];
        canBeDiamondExtender = new boolean[superClasses.length];
        for(int i=0; i<superClasses.length; i++){
          (superClasses[i] = XClassPtr.load(inputStream)).getXClassNonNull(virtualMachine);
          canBeDiamondExtender[i] = true;
        }
        checkDiamonds(new HashMap<XClass, XClass>());
        genericInfos = new XGenericInfo[inputStream.readUnsignedByte()];
        for(int i=0; i<genericInfos.length; i++){
          genericInfos[i] = new XGenericInfo(virtualMachine, inputStream);
        }
        fields = new XField[inputStream.readUnsignedShort()];
        for(int i=0; i<fields.length; i++){
          super.addChild(fields[i] = new XField(this, inputStream));
        }
        methods = new XMethod[inputStream.readUnsignedShort()];
        for(int i=0; i<methods.length; i++){
          super.addChild(methods[i] = new XMethod(this, inputStream));
          if(methods[i].isConstructor() && !XModifier.isStatic(methods[i].getModifier())){
            XClass[] superClasses = methods[i].getExplizitSuperInvokes();
            for(int j=0; j<superClasses.length; j++){
              for(int k=0; k<this.superClasses.length; k++){
                if(superClasses[j] == this.superClasses[k].getXClassNonNull(virtualMachine)){
                  canBeDiamondExtender[k] = false;
                  break;
                }
              }
            }
          }
        }
        state = STATE_LOADED;
        virtualMachine.getClassProvider().addClassForLoading(this);
      }catch(Throwable e){
        state = STATE_ERRORED;
        if(!(e instanceof XRuntimeException)){
          e = new XRuntimeException(e, "Error while loading class %s", getName());
        }
        throw (XRuntimeException)e;
      }
    }
  }
View Full Code Here

  private void checkDiamondAbleFor(XClass xClass) {
    for(int i=0; i<superClasses.length; i++){
      if(superClasses[i].getXClassNonNull(virtualMachine)==xClass){
        if(canBeDiamondExtender[i])
          return;
        throw new XRuntimeException("Class %s can be used as diamond base", xClass);
      }
    }
    throw new XRuntimeException("Oh, this should never be happened, this is a fatal error :(");
  }
View Full Code Here

        state = STATE_POST_LOADING;
        for(int i=0; i<superClasses.length; i++){
          XClass xClass = superClasses[i].getXClass(virtualMachine);
          xClass.postLoad();
          if(xClass.state!=STATE_RUNNABLE){
            throw new XRuntimeException("Class %s isn't inited correctly, so %s can't inited", xClass, this);
          }
        }
       
        state = STATE_RUNNABLE;
        XMethod xMethod = getMethod("<staticInit>", new String[0], "void");
        virtualMachine.getThreadProvider().importantInterrupt("Static "+getName(), xMethod, new XGenericClass[0], new long[0]);
      }catch(Throwable e){
        state = STATE_ERRORED;
        if(!(e instanceof XRuntimeException)){
          e = new XRuntimeException(e, "Error while post loading class %s", getName());
        }
        throw (XRuntimeException)e;
      }
    }
  }
View Full Code Here

    }
  }

  public int getStaticFieldIndex(int sizeInObject) {
    if(state!=STATE_LOADING)
      throw new XRuntimeException("You can't get a field index now");
    int ret = staticFieldCount;
    staticFieldCount += sizeInObject;
    return ret;
  }
View Full Code Here

    return ret;
  }

  public int getFieldIndex(int sizeInObject) {
    if(state!=STATE_LOADING)
      throw new XRuntimeException("You can't get a field index now");
    int ret = fieldCount;
    fieldCount += sizeInObject;
    return ret;
  }
View Full Code Here

    return ret;
  }

  public int getMethodIndex() {
    if(state!=STATE_LOADING)
      throw new XRuntimeException("You can't get a method index now");
    return methodCount++;
  }
View Full Code Here

    if(field==null){
      XClass xClass = vm.getClassProvider().getXClass(className);
      field = xClass.getField(fieldName);
      XChecks.checkAccess(methodExecutor.getMethod().getDeclaringClass(), field);
      if(!field.getType().equals(fieldType)){
        throw new XRuntimeException("Type of field %s has changed", field);
      }
      if(XModifier.isStatic(field.getModifier())){
        throw new XRuntimeException("Field %s is static", field);
      }
    }
  }
View Full Code Here

      rec++;
      try{
        createClass(name);
        xPackage = rootPackage.getChild(name);
        if(xPackage==null){
          throw new XRuntimeException("Class %s not found", name);
        }
        if(rec==1){
          postLoad();
        }
      }catch(Throwable e){
        rec--;
        if(!(e instanceof XRuntimeException)){
          e = new XRuntimeException(e, "Native error while load Class %s", name);
        }
        throw (XRuntimeException)e;
      }
      rec--;
    }
    if(xPackage instanceof XClass){
      XClass xClass = (XClass)xPackage;
      if(xClass.getState()==XClass.STATE_RUNNABLE){
        return xClass;
      }
    }
    throw new XRuntimeException("Class %s not found", name);
  }
View Full Code Here

TOP

Related Classes of xscript.runtime.XRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.