⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pass3averifier.java

📁 Java Bytecode Editor 是一个 JAVA 的字节码反汇编和修改器。它可以很方便的修改已经编译成 Class 文件的 JAVA 文件。
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
				if (name.equals(Constants.CONSTRUCTOR_NAME)){
					constraintViolated(o, "Method to invoke must not be '"+Constants.CONSTRUCTOR_NAME+"'.");
				}
				if (name.equals(Constants.STATIC_INITIALIZER_NAME)){
					constraintViolated(o, "Method to invoke must not be '"+Constants.STATIC_INITIALIZER_NAME+"'.");
				}
			}
		
			// The LoadClassType is the method-declaring class, so we have to check the other types.
			
			Type t = o.getReturnType(cpg);
			if (t instanceof ArrayType){
				t = ((ArrayType) t).getBasicType();
			}
			if (t instanceof ObjectType){
				Verifier v = VerifierFactory.getVerifier(((ObjectType) t).getClassName());
				VerificationResult vr = v.doPass2();
				if (vr.getStatus() != VerificationResult.VERIFIED_OK){
					constraintViolated(o, "Return type class/interface could not be verified successfully: '"+vr.getMessage()+"'.");
				}
			}
			
			Type[] ts = o.getArgumentTypes(cpg);
			for (int i=0; i<ts.length; i++){
				t = ts[i];
				if (t instanceof ArrayType){
					t = ((ArrayType) t).getBasicType();
				}
				if (t instanceof ObjectType){
					Verifier v = VerifierFactory.getVerifier(((ObjectType) t).getClassName());
					VerificationResult vr = v.doPass2();
					if (vr.getStatus() != VerificationResult.VERIFIED_OK){
						constraintViolated(o, "Argument type class/interface could not be verified successfully: '"+vr.getMessage()+"'.");
					}
				}
			}
			
		}
		
		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitINSTANCEOF(INSTANCEOF o){
			indexValid(o, o.getIndex());
			Constant c = cpg.getConstant(o.getIndex());
			if (!	(c instanceof ConstantClass)){
				constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitCHECKCAST(CHECKCAST o){
			indexValid(o, o.getIndex());
			Constant c = cpg.getConstant(o.getIndex());
			if (!	(c instanceof ConstantClass)){
				constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitNEW(NEW o){
			indexValid(o, o.getIndex());
			Constant c = cpg.getConstant(o.getIndex());
			if (!	(c instanceof ConstantClass)){
				constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
			}
			else{
				ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() ));
				Type t = Type.getType("L"+cutf8.getBytes()+";");
				if (t instanceof ArrayType){
					constraintViolated(o, "NEW must not be used to create an array.");
				}
			}
			
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitMULTIANEWARRAY(MULTIANEWARRAY o){
			indexValid(o, o.getIndex());
			Constant c = cpg.getConstant(o.getIndex());
			if (!	(c instanceof ConstantClass)){
				constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
			}
			int dimensions2create = o.getDimensions();
			if (dimensions2create < 1){
				constraintViolated(o, "Number of dimensions to create must be greater than zero.");
			}
			Type t = o.getType(cpg);
			if (t instanceof ArrayType){
				int dimensions = ((ArrayType) t).getDimensions();
				if (dimensions < dimensions2create){
					constraintViolated(o, "Not allowed to create array with more dimensions ('+dimensions2create+') than the one referenced by the CONSTANT_Class '"+t+"'.");
				}
			}
			else{
				constraintViolated(o, "Expecting a CONSTANT_Class referencing an array type. [Constraint not found in The Java Virtual Machine Specification, Second Edition, 4.8.1]");
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitANEWARRAY(ANEWARRAY o){
			indexValid(o, o.getIndex());
			Constant c = cpg.getConstant(o.getIndex());
			if (!	(c instanceof ConstantClass)){
				constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
			}
			Type t = o.getType(cpg);
			if (t instanceof ArrayType){
				int dimensions = ((ArrayType) t).getDimensions();
				if (dimensions >= 255){
					constraintViolated(o, "Not allowed to create an array with more than 255 dimensions.");
				}
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitNEWARRAY(NEWARRAY o){
			byte t = o.getTypecode();
			if (!	(	(t == Constants.T_BOOLEAN)	||
							(t == Constants.T_CHAR)			||
							(t == Constants.T_FLOAT)		||
							(t == Constants.T_DOUBLE)		||
							(t == Constants.T_BYTE)			||
							(t == Constants.T_SHORT)		||
							(t == Constants.T_INT)			||
							(t == Constants.T_LONG)	)	){
				constraintViolated(o, "Illegal type code '+t+' for 'atype' operand.");
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitILOAD(ILOAD o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitFLOAD(FLOAD o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitALOAD(ALOAD o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}
		
		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitISTORE(ISTORE o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}
		
		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitFSTORE(FSTORE o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitASTORE(ASTORE o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitIINC(IINC o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitRET(RET o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative.");
			}
			else{
				int maxminus1 =  max_locals()-1;
				if (idx > maxminus1){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-1 '"+maxminus1+"'.");
				}
			}
		}

		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitLLOAD(LLOAD o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]");
			}
			else{
				int maxminus2 =  max_locals()-2;
				if (idx > maxminus2){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'.");
				}
			}
		}
		
		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitDLOAD(DLOAD o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]");
			}
			else{
				int maxminus2 =  max_locals()-2;
				if (idx > maxminus2){
					constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'.");
				}
			}
		}
		
		/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
		public void visitLSTORE(LSTORE o){
			int idx = o.getIndex();
			if (idx < 0){
				constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]");
			}
			else{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -