package com.db4o.test;

import com.db4o.lib.Platform;

public class MasterMonster extends RTest
{
	public Object[] ooo;
	static transient int idgen = 0;
	transient int id = 0;

	public MasterMonster(){
		id = idgen ++;
	}

	public void set(int ver){
		Object[] classes = allClassesButThis();
		ooo = new Object[classes.length];
		for(int i = 0;i < classes.length; i++){
			try{
				RTestable test = (RTestable)classes[i];
				if(Platform.jdk2 || !test.jdk2() ){
					ooo[i] = test.newInstance();
					test.set(ooo[i], ver);
				}
			}catch (Exception e){
				throw new RuntimeException("MasterMonster instantiation failed.");
			}
		}
	}

	static Object[] allClassesButThis(){
		Object[] all = Regression.allClasses();
		Object[] classes = new Object[all.length - 1];
		System.arraycopy(all,0,classes,0,all.length - 1);
		return classes;
	}

	public boolean jdk2(){
		return false;
	}

}
