/** * Executes the actual work of reseting the given elements document. * * @param element the element * @param monitor the progress monitor * @throws CoreException if resetting fails * @since 3.0 */ protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info != null) { IDocument original = null; IStatus status = null; try { original = createDocument(element); } catch (CoreException x) { status = x.getStatus(); } info.fStatus = status; if (original != null) { fireElementContentAboutToBeReplaced(element); info.fDocument.set(original.get()); if (info.fCanBeSaved) { info.fCanBeSaved = false; addUnchangedElementListeners(element, info); } fireElementContentReplaced(element); fireElementDirtyStateChanged(element, false); } } }
/* * @see org.eclipse.ui.texteditor.AbstractDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor) */ protected void execute(IProgressMonitor pm) throws CoreException { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info != null) { if (info.fDocument != document) { Status status = new Status( IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.ERROR, EditorMessages.AbstractDocumentProvider_error_save_inuse, null); throw new CoreException(status); } doSaveDocument(pm, element, document, overwrite); if (pm != null && pm.isCanceled()) return; info.fCanBeSaved = false; addUnchangedElementListeners(element, info); fireElementDirtyStateChanged(element, false); } else { doSaveDocument(pm, element, document, overwrite); } }
public static char getChar__Ljava_lang_Object_2__C(MJIEnv env, int objRef, int fobjRef) { FieldInfo fi = getFieldInfo(env, objRef); ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, CharFieldInfo.class, "char"); if (ei != null) { return ei.getCharField(fi); } return 0; }
public static int getInt__Ljava_lang_Object_2__I(MJIEnv env, int objRef, int fobjRef) { FieldInfo fi = getFieldInfo(env, objRef); ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, IntegerFieldInfo.class, "int"); if (ei != null) { return ei.getIntField(fi); } return 0; }
public static long getLong__Ljava_lang_Object_2__J(MJIEnv env, int objRef, int fobjRef) { FieldInfo fi = getFieldInfo(env, objRef); ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, LongFieldInfo.class, "long"); if (ei != null) { return ei.getLongField(fi); } return 0; }
public static float getFloat__Ljava_lang_Object_2__F(MJIEnv env, int objRef, int fobjRef) { FieldInfo fi = getFieldInfo(env, objRef); ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, FloatFieldInfo.class, "float"); if (ei != null) { return ei.getFloatField(fi); } return 0; }
public static boolean getBoolean__Ljava_lang_Object_2__Z(MJIEnv env, int objRef, int fobjRef) { FieldInfo fi = getFieldInfo(env, objRef); ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, BooleanFieldInfo.class, "boolean"); if (ei != null) { return ei.getBooleanField(fi); } return false; }
public static double getDouble__Ljava_lang_Object_2__D(MJIEnv env, int objRef, int fobjRef) { FieldInfo fi = getFieldInfo(env, objRef); ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, DoubleFieldInfo.class, "double"); if (ei != null) { return ei.getDoubleField(fi); } return 0; }
/* * @see IDocumentProviderExtension#setCanSaveDocument(Object) * @since 2.0 */ public void setCanSaveDocument(Object element) { if (element != null) { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info != null) { info.fCanBeSaved = true; removeUnchangedElementListeners(element, info); fireElementDirtyStateChanged(element, info.fCanBeSaved); } } }
@MJI public int getInt__Ljava_lang_Object_2__I(MJIEnv env, int objRef, int fobjRef, FeatureExpr ctx) { FieldInfo fi = getFieldInfo(ctx, env, objRef); ElementInfo ei = getCheckedElementInfo(env, objRef, fi, fobjRef, IntegerFieldInfo.class, "int", false, ctx); if (ei != null) { return ei.getIntField(fi).simplify(ctx).getValue(); } return 0; }
public boolean canEnter(ThreadInfo th) { if (isSynchronized()) { ElementInfo ei = getBlockedObject(th, true); // <?> pcm - the other way round would be intuitive return ei.canLock(th); } return true; }
protected void execute(IProgressMonitor monitor) throws CoreException { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info == null) return; doValidateState(element, computationContext); doUpdateStateCache(element); info.fIsStateValidated = true; fireElementStateValidationChanged(element, true); }
@MJI public float getFloat__Ljava_lang_Object_2__F( MJIEnv env, int objRef, int fobjRef, FeatureExpr ctx) { FieldInfo fi = getFieldInfo(ctx, env, objRef); ElementInfo ei = getCheckedElementInfo(env, objRef, fi, fobjRef, FloatFieldInfo.class, "float", false, ctx); if (ei != null) { return ei.getFloatField(fi).getValue(); } return 0; }
public static void setInt__Ljava_lang_Object_2I__V(MJIEnv env, int objRef, int fobjRef, int val) { FieldInfo fi = getFieldInfo(env, objRef); if (!isAvailable(env, fi, fobjRef)) { return; } ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, IntegerFieldInfo.class, "int"); if (ei != null) { ei.setIntField(fi, val); } }
/* * @see IDocumentProviderExtension#updateStateCache(Object) * @since 2.0 */ public final void updateStateCache(Object element) throws CoreException { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info != null) { boolean wasReadOnly = isReadOnly(element); doUpdateStateCache(element); if (invalidatesState(element, wasReadOnly)) { info.fIsStateValidated = false; fireElementStateValidationChanged(element, false); } } }
public static void setDouble__Ljava_lang_Object_2D__V( MJIEnv env, int objRef, int fobjRef, double val) { FieldInfo fi = getFieldInfo(env, objRef); if (!isAvailable(env, fi, fobjRef)) { return; } ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, DoubleFieldInfo.class, "double"); if (ei != null) { ei.setDoubleField(fi, val); } }
public static void setBoolean__Ljava_lang_Object_2Z__V( MJIEnv env, int objRef, int fobjRef, boolean val) { FieldInfo fi = getFieldInfo(env, objRef); if (!isAvailable(env, fi, fobjRef)) { return; } ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, BooleanFieldInfo.class, "boolean"); if (ei != null) { ei.setBooleanField(fi, val); } }
@MJI public boolean getBoolean__Ljava_lang_Object_2__Z( MJIEnv env, int objRef, int fobjRef, FeatureExpr ctx) { FieldInfo fi = getFieldInfo(ctx, env, objRef); ElementInfo ei = getCheckedElementInfo( env, objRef, fi, fobjRef, BooleanFieldInfo.class, "boolean", false, ctx); if (ei != null) { return ei.getBooleanField(fi).getValue(); } return false; }
@MJI public void setInt__Ljava_lang_Object_2I__V( MJIEnv env, int objRef, int fobjRef, int val, FeatureExpr ctx) { FieldInfo fi = getFieldInfo(ctx, env, objRef); if (!isAvailable(env, fi, fobjRef, ctx)) { return; } ElementInfo ei = getCheckedElementInfo(env, objRef, fi, fobjRef, IntegerFieldInfo.class, "int", true, ctx); if (ei != null) { ei.setIntField(ctx, fi, One.valueOf(val)); } }
private void enter(ThreadInfo ti) { if (isSynchronized()) { ElementInfo ei = getBlockedObject(ti, true); ei.lock(ti); if (isStatic() && isClinit()) { ci.setInitializing(ti); } } StackFrame frame = new StackFrame(this, ti.getTopFrame()); ti.pushFrame(frame); ti.getVM().notifyMethodEntered(ti, this); }
@MJI public void setDouble__Ljava_lang_Object_2D__V( MJIEnv env, int objRef, int fobjRef, double val, FeatureExpr ctx) { FieldInfo fi = getFieldInfo(ctx, env, objRef); if (!isAvailable(env, fi, fobjRef, ctx)) { return; } ElementInfo ei = getCheckedElementInfo(env, objRef, fi, fobjRef, DoubleFieldInfo.class, "double", true, ctx); if (ei != null) { ei.setDoubleField(ctx, fi, new One<>(val)); } }
private void checkAndCopyAttributes(Attributes attributes, ElementInfo elInfo) throws SAXException, RDFParseException { Atts atts = new Atts(attributes.getLength()); int attCount = attributes.getLength(); for (int i = 0; i < attCount; i++) { String qName = attributes.getQName(i); String value = attributes.getValue(i); // attributes starting with "xml" should be ignored, except for the // ones that are handled by this parser (xml:lang and xml:base). if (qName.startsWith("xml")) { if (qName.equals("xml:lang")) { elInfo.xmlLang = value; } else if (qName.equals("xml:base")) { elInfo.setBaseURI(value); } } else { String namespace = attributes.getURI(i); String localName = attributes.getLocalName(i); // A limited set of unqualified attributes must be supported by // parsers, as is specified in section 6.1.4 of the spec if ("".equals(namespace)) { if (localName.equals("ID") || localName.equals("about") || localName.equals("resource") || localName.equals("parseType") || localName.equals("type")) { rdfParser.reportWarning( "use of unqualified attribute " + localName + " has been deprecated"); namespace = RDF.NAMESPACE; } } if ("".equals(namespace)) { rdfParser.reportError( "unqualified attribute '" + qName + "' not allowed", XMLParserSettings.FAIL_ON_INVALID_QNAME); } Att att = new Att(namespace, localName, qName, value); atts.addAtt(att); } } elInfo.atts = atts; }
/* * @see IDocumentProvider#connect(Object) */ public final void connect(Object element) throws CoreException { ElementInfo info = (ElementInfo) fElementInfoMap.get(element); if (info == null) { info = createElementInfo(element); if (info == null) info = new ElementInfo(null, null); info.fElement = element; addUnchangedElementListeners(element, info); fElementInfoMap.put(element, info); if (fElementInfoMap.size() == 1) connected(); } ++info.fCount; }
@MJI public int get__Ljava_lang_Object_2__Ljava_lang_Object_2( MJIEnv env, int objRef, int fobjRef, FeatureExpr ctx) { FieldInfo fi = getFieldInfo(ctx, env, objRef); ElementInfo ei = getCheckedElementInfo( env, objRef, fi, fobjRef, null, null, false, ctx); // no type check here if (ei == null) { return 0; } if (!(fi instanceof ReferenceFieldInfo)) { // primitive type, we need to box it if (fi instanceof DoubleFieldInfo) { Conditional<Double> d = ei.getDoubleField(fi); return env.newDouble(ctx, d); } else if (fi instanceof FloatFieldInfo) { Conditional<Float> f = ei.getFloatField(fi); return env.newFloat(ctx, f); } else if (fi instanceof LongFieldInfo) { Conditional<Long> l = ei.getLongField(fi); return env.newLong(ctx, l); } else if (fi instanceof IntegerFieldInfo) { // this might actually represent a plethora of types Conditional<Integer> i = ei.getIntField(fi); return env.newInteger(ctx, i); } else if (fi instanceof BooleanFieldInfo) { Conditional<Boolean> b = ei.getBooleanField(fi); return env.newBoolean(b.getValue()); } else if (fi instanceof ByteFieldInfo) { Conditional<Byte> z = ei.getByteField(fi); return env.newByte(ctx, z); } else if (fi instanceof CharFieldInfo) { Conditional<Character> c = ei.getCharField(fi); return env.newCharacter(ctx, c); } else if (fi instanceof ShortFieldInfo) { Conditional<Short> s = ei.getShortField(fi); return env.newShort(ctx, s); } } else { // it's a reference int ref = ei.getReferenceField(fi).simplify(ctx).getValue(); // we internally store it as int return ref; } env.throwException(ctx, "java.lang.IllegalArgumentException", "unknown field type"); return MJIEnv.NULL; }
public static int get__Ljava_lang_Object_2__Ljava_lang_Object_2( MJIEnv env, int objRef, int fobjRef) { FieldInfo fi = getFieldInfo(env, objRef); ElementInfo ei = getCheckedElementInfo(env, fi, fobjRef, null, null); // no type check here if (ei == null) { return 0; } if (!(fi instanceof ReferenceFieldInfo)) { // primitive type, we need to box it if (fi instanceof DoubleFieldInfo) { double d = ei.getDoubleField(fi); return env.newDouble(d); } else if (fi instanceof FloatFieldInfo) { float f = ei.getFloatField(fi); return env.newFloat(f); } else if (fi instanceof LongFieldInfo) { long l = ei.getLongField(fi); return env.newLong(l); } else if (fi instanceof IntegerFieldInfo) { // this might actually represent a plethora of types int i = ei.getIntField(fi); return env.newInteger(i); } else if (fi instanceof BooleanFieldInfo) { boolean b = ei.getBooleanField(fi); return env.newBoolean(b); } else if (fi instanceof ByteFieldInfo) { byte z = ei.getByteField(fi); return env.newByte(z); } else if (fi instanceof CharFieldInfo) { char c = ei.getCharField(fi); return env.newCharacter(c); } else if (fi instanceof ShortFieldInfo) { short s = ei.getShortField(fi); return env.newShort(s); } } else { // it's a reference int ref = ei.getReferenceField(fi); // we internally store it as int return ref; } env.throwException("java.lang.IllegalArgumentException", "unknown field type"); return MJIEnv.NULL; }
public String getNamespace(String prefix) { String result = null; if (namespaceMap != null) { result = namespaceMap.get(prefix); } if (result == null && parent != null) { result = parent.getNamespace(prefix); } return result; }
public StaticElementInfo( int id, ClassInfo ci, Fields f, Monitor m, ThreadInfo ti, ElementInfo eiClsObj) { super(id, ci, f, m, ti); if (eiClsObj != null) { classObjectRef = eiClsObj.getObjectRef(); } // <2do> not ideal, should be in superclass, but we need the classObjectRef for init referencingThreads = createThreadInfoSet(ti); // initialization depends on subclass and policy setSharednessFromReferencingThreads(); // initial attributes? }
/** * Inserts prefix mappings from an XML Literal's context for all prefixes that are used in the XML * Literal and that are not defined in the XML Literal itself. */ private void insertUsedContextPrefixes() { int unknownPrefixesCount = unknownPrefixesInXMLLiteral.size(); if (unknownPrefixesCount > 0) { // Create a String with all needed context prefixes StringBuilder contextPrefixes = new StringBuilder(1024); ElementInfo topElement = peekStack(); for (int i = 0; i < unknownPrefixesCount; i++) { String prefix = unknownPrefixesInXMLLiteral.get(i); String namespace = topElement.getNamespace(prefix); if (namespace != null) { appendNamespaceDecl(contextPrefixes, prefix, namespace); } } // Insert this String before the first '>' character int endOfFirstStartTag = charBuf.indexOf(">"); charBuf.insert(endOfFirstStartTag, contextPrefixes.toString()); } unknownPrefixesInXMLLiteral.clear(); }
public void leave(ThreadInfo ti) { // <2do> - that's not really enough, we might have suspicious bytecode that fails // to release locks acquired by monitor_enter (e.g. by not having a handler that // monitor_exits & re-throws). That's probably shifted into the bytecode verifier // in the future (i.e. outside JPF), but maybe we should add an explicit test here // and report an error if the code does asymmetric locking (according to the specs, // VMs are allowed to silently fix this, so it might run on some and fail on others) if (isSynchronized()) { ElementInfo ei = getBlockedObject(ti, false); ei.unlock(ti); if (isStatic() && isClinit()) { // we just released the lock on the class object, returning from a clinit // now we can consider this class to be initialized. // NOTE this is still part of the RETURN insn of clinit, so ClassInfo.isInitialized // is protected ci.setInitialized(); } } ti.getVM().notifyMethodExited(ti, this); }
private static boolean setValue(MJIEnv env, FieldInfo fi, int obj, int value, Object attr) { ClassInfo fieldClassInfo = fi.getClassInfo(); String className = fieldClassInfo.getName(); String fieldType = fi.getType(); try { ClassInfo tci = fi.getTypeClassInfo(); if (tci.isPrimitive()) { if (value == MJIEnv.NULL) { return false; } // checks whether unboxing can be done by accessing the field "value" final String fieldName = "value"; FieldInfo finfo = env.getElementInfo(value).getFieldInfo(fieldName); if (finfo == null) { return false; } ElementInfo ei = fi.isStatic() ? fi.getClassInfo().getStaticElementInfo() : env.getElementInfo(obj); ei.setFieldAttr(fi, attr); if ("boolean".equals(fieldType)) { boolean val = env.getBooleanField(value, fieldName); ei.setBooleanField(fi, val); return true; } else if ("byte".equals(fieldType)) { byte val = env.getByteField(value, fieldName); ei.setByteField(fi, val); return true; } else if ("char".equals(fieldType)) { char val = env.getCharField(value, fieldName); ei.setCharField(fi, val); return true; } else if ("short".equals(fieldType)) { short val = env.getShortField(value, fieldName); ei.setShortField(fi, val); return true; } else if ("int".equals(fieldType)) { int val = env.getIntField(value, fieldName); ei.setIntField(fi, val); return true; } else if ("long".equals(fieldType)) { long val = env.getLongField(value, fieldName); ei.setLongField(fi, val); return true; } else if ("float".equals(fieldType)) { float val = env.getFloatField(value, fieldName); ei.setFloatField(fi, val); return true; } else if ("double".equals(fieldType)) { double val = env.getDoubleField(value, fieldName); ei.setDoubleField(fi, val); return true; } else { return false; } } else { // it's a reference if (value != MJIEnv.NULL) { String type = env.getTypeName(value); // this is an instance so the ClassInfo has to be registered ClassInfo valueCI = ClassInfo.getResolvedClassInfo(type); if (!valueCI.isInstanceOf(tci)) { return false; } } ElementInfo ei = fi.isStatic() ? fi.getClassInfo().getStaticElementInfo() : env.getElementInfo(obj); ei.setFieldAttr(fi, attr); if (fi.isStatic()) { env.setStaticReferenceField(className, fi.getName(), value); } else { env.setReferenceField(obj, fi.getName(), value); } return true; } } catch (NoClassInfoException cx) { env.throwException("java.lang.NoClassDefFoundError", cx.getMessage()); return false; } }