Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Remove optimization code
Browse files Browse the repository at this point in the history
  • Loading branch information
HOHOWU committed Nov 28, 2017
1 parent f54663a commit 9805bc9
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 852 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ public boolean useNamespace() {
return false;
}

public final boolean isDefault() {
return true;
}

public void declareNamespace(T o, XMLSerializer w) throws AccessorException {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,6 @@ public boolean useNamespace() {
return xacc.useNamespace();
}

public boolean isDefault() {
return false;
}

public void declareNamespace(BeanT bean, XMLSerializer w) throws AccessorException {
try {
xacc.declareNamespace(bean,w);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ public QName[] getTypeNames() {
return new QName[]{getTypeName()};
}

public boolean isDefault() {
return false;
}

@Override
public Class getClazz() {
return clazz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ protected FilterTransducer(Transducer<T> core) {
this.core = core;
}

public final boolean isDefault() {
// this must be used as a decorating transducer,
// so it may never be default.
return false;
}

public boolean useNamespace() {
return core.useNamespace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import com.sun.istack.NotNull;
import com.sun.xml.bind.api.AccessorException;
import com.sun.xml.bind.v2.model.runtime.RuntimePropertyInfo;
import com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedTransducedAccessorFactory;

import org.xml.sax.SAXException;

Expand All @@ -69,14 +68,6 @@
*/
public interface Transducer<ValueT> {

/**
* If this {@link Transducer} is the default transducer for the <code>ValueT</code>,
* this method returns true.
*
* Used exclusively by {@link OptimizedTransducedAccessorFactory#get(RuntimePropertyInfo)}
*/
boolean isDefault();

/**
* If true, this {@link Transducer} doesn't declare any namespace,
* and therefore {@link #declareNamespace(Object, XMLSerializer)} is no-op.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import com.sun.xml.bind.v2.model.core.Adapter;
import com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder;
import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory;
import com.sun.xml.bind.v2.runtime.unmarshaller.Loader;
import com.sun.xml.bind.v2.runtime.unmarshaller.Receiver;
import com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext;
Expand Down Expand Up @@ -279,14 +278,7 @@ public void set(BeanT bean, ValueT value) {

@Override
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context) {
if (context != null && context.fastBoot)
// let's not waste time on doing this for the sake of faster boot.
return this;
Accessor<BeanT, ValueT> acc = OptimizedAccessorFactory.get(f);
if (acc != null)
return acc;
else
return this;
return this;
}
}

Expand Down Expand Up @@ -392,18 +384,7 @@ private AccessorException handleInvocationTargetException(InvocationTargetExcept

@Override
public Accessor<BeanT, ValueT> optimize(JAXBContextImpl context) {
if (getter == null || setter == null)
// if we aren't complete, OptimizedAccessor won't always work
return this;
if (context != null && context.fastBoot)
// let's not waste time on doing this for the sake of faster boot.
return this;

Accessor<BeanT, ValueT> acc = OptimizedAccessorFactory.get(getter, setter);
if (acc != null)
return acc;
else
return this;
return this;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import com.sun.xml.bind.v2.runtime.Transducer;
import com.sun.xml.bind.v2.runtime.XMLSerializer;
import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedTransducedAccessorFactory;
import com.sun.xml.bind.v2.runtime.unmarshaller.Patcher;
import com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext;
import com.sun.xml.bind.v2.runtime.unmarshaller.LocatorEx;
Expand Down Expand Up @@ -164,11 +163,6 @@ public static <T> TransducedAccessor<T> get(JAXBContextImpl context, RuntimeNonE
if(prop.id()==ID.IDREF)
return new IDREFTransducedAccessorImpl(prop.getAccessor());

if(xducer.isDefault() && context != null && !context.fastBoot) {
TransducedAccessor xa = OptimizedTransducedAccessorFactory.get(prop);
if(xa!=null) return xa;
}

if(xducer.useNamespace())
return new CompositeContextDependentTransducedAccessorImpl( context, xducer, prop.getAccessor() );
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,42 +62,6 @@ class AccessorInjector {
logger.info("The optimized code generation is disabled");
}

/**
* Loads the optimized class and returns it.
*
* @return null
* if it fails for some reason.
*/
public static Class<?> prepare(
Class beanClass, String templateClassName, String newClassName, String... replacements ) {

if(noOptimize)
return null;

try {
ClassLoader cl = SecureLoader.getClassClassLoader(beanClass);
if(cl==null) return null; // how do I inject classes to this "null" class loader? for now, back off.

Class c = Injector.find(cl,newClassName);
if (c==null) {
byte[] image = tailor(templateClassName,newClassName,replacements);
if (image==null) {
return null;
}
c = Injector.inject(cl,newClassName,image);
if (c == null) {
Injector.find(cl, newClassName);
}
}
return c;
} catch(SecurityException e) {
// we don't have enough permission to do this
logger.log(Level.INFO,"Unable to create an optimized TransducedAccessor ",e);
return null;
}
}


/**
* Customizes a class file by replacing constant pools.
*
Expand Down
Loading

0 comments on commit 9805bc9

Please sign in to comment.