List of usage examples for org.aspectj.apache.bcel.classfile Unknown getBytes
public final byte[] getBytes()
From source file:br.jabuti.device.DeviceProbeInsert.java
License:Open Source License
public Map instrument() throws InvalidInstructionException, InvalidStackArgument { Map mp = super.instrument(); Hashtable hs = new Hashtable(); Iterator it = mp.keySet().iterator(); // para cada classe: while (it.hasNext()) { String className = (String) it.next(); JavaClass jv = (JavaClass) mp.get(className); // verifica se esta classe jah foi instrumentada por // esse instrumentador Attribute[] atr = jv.getAttributes(); boolean achou = false; for (int j = 0; j < atr.length && !achou; j++) { if (atr[j] instanceof Unknown) { Unknown uatr = (Unknown) atr[j]; byte[] b = uatr.getBytes(); achou = Arrays.equals(b, JABUTI_J2ME_INSTR_ATTRIBUTE.getBytes()); }/*from w w w . j a v a2s. c o m*/ } // se estah em inst eh pra instrumentar a classe if ((!achou) && className.equals(baseClass)) { // chama a rotina que faz a instrumentacao jv = doMethodInstrument(jv); hs.put(className, jv); } else { // coloca o codigo sem instrumentar hs.put(className, jv); } } return hs; }
From source file:br.jabuti.probe.desktop.DefaultProbeInsert.java
License:Open Source License
public Map instrument() throws InvalidInstructionException, InvalidStackArgument { String[] userClass = null;/*from w ww . j a va2 s . co m*/ HashSet inst = new HashSet(); if (instrumentList != null) { inst.addAll(instrumentList); } // pega o nome de todas as classes instrumentaveis do programa userClass = prog.getCodeClasses(); Hashtable hs = new Hashtable(); // para cada classe: for (int i = 0; i < userClass.length; i++) { RClassCode r = (RClassCode) prog.get(userClass[i]); JavaClass jv = r.getTheClass(); // verifica se esta classe jah foi instrumentada por // esse instrumentador Attribute[] atr = jv.getAttributes(); boolean achou = false; for (int j = 0; j < atr.length && !achou; j++) { if (atr[j] instanceof Unknown) { Unknown uatr = (Unknown) atr[j]; byte[] b = uatr.getBytes(); achou = Arrays.equals(b, JABUTI_DEFAULT_INSTR_ATTRIBUTE.getBytes()); } } // se estah em inst eh pra instrumentar a classe if ((!achou) && inst.contains(userClass[i]) && !jv.isInterface()) { // chama a rotina que faz a instrumentacao try { jv = doDefaultInstrument(jv, userClass[i]); hs.put(r.getName(), jv); } catch (Exception e) { hs.put(userClass[i], jv); } inst.remove(userClass[i]); } else { // coloca o codigo sem instrumentar hs.put(userClass[i], jv); } } return hs; }
From source file:br.jabuti.probe.mobiledevice.HostProbeInsert.java
License:Open Source License
public Map instrument() throws InvalidInstructionException, InvalidStackArgument { HashSet inst = new HashSet(); Map mp = super.instrument(); if (classList != null) { inst.addAll(classList);// www . j a va 2s . c o m } Hashtable hs = new Hashtable(); Iterator it = mp.keySet().iterator(); // para cada classe: while (it.hasNext()) { String className = (String) it.next(); JavaClass jv = (JavaClass) mp.get(className); // verifica se esta classe jah foi instrumentada por // esse instrumentador Attribute[] atr = jv.getAttributes(); boolean achou = false; for (int j = 0; j < atr.length && !achou; j++) { if (atr[j] instanceof Unknown) { Unknown uatr = (Unknown) atr[j]; byte[] b = uatr.getBytes(); achou = Arrays.equals(b, JABUTI_HOST_INSTR_ATTRIBUTE.getBytes()); } } // se estah em inst eh pra instrumentar a classe if ((!achou) && inst.contains(className)) { // chama a rotina que faz a instrumentacao jv = doClassInstrument(jv); jv = doMethodInstrument(jv); inst.remove(className); hs.put(className, jv); } else { // coloca o codigo sem instrumentar hs.put(className, jv); } } return hs; }