--- /dev/null
+/*
+ * Created on Mar 7, 2008
+ */
+package test1;
+
+public interface SelectAction<T>{
+
+ public void select(T object);
+
+ public T getSelected();
+
+ public void setSelected(T object);
+
+ public void deselect();
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Created on Sep 4, 2008
+ */
+package test1;
+
+public aspect SelectActionAspect {
+
+ private T SelectAction<T>.selected;
+
+ public void SelectAction<T>.select(T object){
+ this.selected = object;
+ }
+
+ public T SelectAction<T>.getSelected(){
+ return selected;
+ }
+
+ public void SelectAction<T>.setSelected(T object){
+ this.selected = object;
+ }
+
+ public void SelectAction<T>.deselect(){
+ this.selected = null;
+ }
+
+}
--- /dev/null
+package test2;
+import test1.SelectAction;
+
+
+/*
+ * Created on Sep 11, 2008
+ */
+
+public class ProfileAction implements SelectAction<Object>{
+
+}
--- /dev/null
+import java.util.*;
+
+interface A {
+
+ List<?> getfoos() ;
+}
+
+aspect X {
+ List<?> A.getFoos() { return null; }
+}
--- /dev/null
+/*
+ * Created on Aug 22, 2008
+ */
+package bug;
+
+
+public enum DuplicateStrategy {
+
+ COMBINE,
+ BEST_MATCH
+
+}
--- /dev/null
+/*
+ * Created on Sep 18, 2008
+ */
+package bug;
+
+
+public class EntityManager {
+
+ public Query createQuery(String query){
+ return new Query();
+ }
+
+ public Object find(Class<?> type, Object id){
+ return new Object();
+ }
+
+ public void merge(Object object){}
+
+ public void persist(Object object){}
+
+ public void remove(Object object){}
+
+}
--- /dev/null
+/*
+ * Created on Aug 8, 2008
+ */
+package bug;
+
+public class EqualityUtils {
+
+ public static boolean equal(Object obj1, Object obj2){
+ if(obj1 == null){
+ if(obj2 == null)
+ return true;
+ return false;
+ } else if(obj2 == null){
+ return false;
+ } else{
+ return obj1.equals(obj2);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Created on Sep 18, 2008
+ */
+package bug;
+
+import java.util.List;
+
+
+public class FailingManager implements PartitionedManager {
+
+ public Class<Object> getManagedType(){
+ return Object.class;
+ }
+
+ public List<String> getDefaultPartitionOrder() {
+ return null;
+ }
+
+ public DuplicateStrategy getPartitionedDuplicateStrategy() {
+ return null;
+ }
+
+}
--- /dev/null
+/*
+ * Created on Sep 18, 2008
+ */
+package bug;
+
+
+public class H2Lookup {
+
+ public static EntityManager em(){
+ return new EntityManager();
+ }
+
+}
--- /dev/null
+/*
+ * Created on Jul 23, 2008
+ */
+package bug;
+
+public interface Localized extends NaturallyComparable{
+
+ public String getLanguage();
+
+}
--- /dev/null
+/*
+ * Created on Jul 25, 2008
+ */
+package bug;
+
+import java.util.List;
+
+
+public interface LocalizedManager extends Manager{
+
+ public Class<? extends Localized> getLocalizedType();
+
+ public List<? extends Localized> getAllInLocale(String language);
+
+ public List<? extends Localized> getAllInLocales(List<String> languages);
+
+ public List<? extends Localized> getAllInDefaultLocales();
+
+ public List<? extends Localized> getBestInLocales(List<String> languages);
+
+ public List<? extends Localized> getBestInDefaultLocales();
+
+ public List<? extends Localized> removeWeakLanguageMatches(List<? extends Localized> localized);
+
+ public List<? extends Localized> removeWeakLanguageMatches(List<? extends Localized> localized, List<String> languageOrder);
+
+ public DuplicateStrategy getLocalizedDuplicateStrategy();
+
+ public List<String> getDefaultLanguageOrder();
+
+}
--- /dev/null
+/*
+ * Created on Jul 25, 2008
+ */
+package bug;
+
+import java.util.List;
+
+public interface Manager {
+
+ public Class<?> getManagedType();
+
+ public <T> T find(Object id);
+
+ public <T> T update(T object);
+
+ public <T> T save(T object);
+
+ public <T> T remove(T object);
+
+ public List<?> getAny();
+
+ public List<?> getAll();
+
+ public Query createQuery(String queryString);
+
+ public EntityManager getEntityManager();
+
+}
\ No newline at end of file
--- /dev/null
+package bug;
+
+import java.util.List;
+
+public aspect ManagerAspect {
+
+ public List<?> Manager.getAny(){
+ return getEntityManager().createQuery("SELECT obj FROM " +
+ getManagedType().getName() + " obj ").getResultList();
+ }
+
+ public List<?> Manager.getAll(){
+ List<?> values = null;
+ if(this instanceof LocalizedManager){
+ LocalizedManager manager = (LocalizedManager)this;
+ values = manager.getAllInDefaultLocales();
+ }
+ else if(this instanceof PartitionedManager){
+ PartitionedManager manager = (PartitionedManager)this;
+ values = manager.getBestInDefaultPartitions();
+ }
+ else{
+ values = getAny();
+ }
+ return values;
+ }
+
+ public <T> T Manager.find(Object id){
+ return (T) getEntityManager().find(getManagedType(), id);
+ }
+
+ public <T> T Manager.save(T object){
+ getEntityManager().persist(object);
+ return object;
+ }
+
+ public <T> T Manager.update(T object){
+ getEntityManager().merge(object);
+ return object;
+ }
+
+ public <T> T Manager.remove(T object){
+ getEntityManager().remove(object);
+ return object;
+ }
+
+ public Query Manager.createQuery(String queryString){
+ EntityManager em = getEntityManager();
+ Query query = em.createQuery(queryString);
+ return query;
+ }
+
+ public EntityManager Manager.getEntityManager() {
+ return H2Lookup.em();
+ }
+
+}
--- /dev/null
+/*
+ * Created on Aug 22, 2008
+ */
+package bug;
+
+
+public interface NaturallyComparable {
+
+ public Object getNaturalId();
+
+ public boolean naturallyEqual(NaturallyComparable to);
+
+}
--- /dev/null
+/*
+ * Created on Aug 22, 2008
+ */
+package bug;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public abstract class NaturallyComparablePruner<T extends NaturallyComparable, O> {
+
+ public List<? extends T> prune(List<? extends T> list, List<O> order){
+ Map<Object, List<T>> sep = new HashMap<Object, List<T>>();
+ for(T obj : list){
+ Object id = obj.getNaturalId();
+ List<T> matches = sep.get(id);
+ if(matches == null){
+ matches = new ArrayList<T>();
+ sep.put(id, matches);
+ }
+ if(matches.size() == 0)
+ matches.add(obj);
+ else{
+ T match = matches.get(0);
+ O yours = getOrdering(match);
+ O mine = getOrdering(obj);
+ if(EqualityUtils.equal(mine, yours))
+ matches.add(obj);
+ else{
+ int yourIndex = order.indexOf(yours);
+ int myIndex = order.indexOf(mine);
+ if(myIndex < yourIndex){
+ matches.clear();
+ matches.add(obj);
+ }
+ }
+ }
+ }
+ List<T> result = new ArrayList<T>();
+ for(List<T> values : sep.values())
+ result.addAll(values);
+ return result;
+ }
+
+ public abstract O getOrdering(T object);
+
+}
--- /dev/null
+/*
+ * Created on Jul 23, 2008
+ */
+package bug;
+
+public interface Partitioned extends NaturallyComparable{
+
+ public String getOwnerId();
+
+ public String getPartitionId();
+
+}
--- /dev/null
+/*
+ * Created on Jul 25, 2008
+ */
+package bug;
+
+import java.util.List;
+
+public interface PartitionedManager extends Manager{
+
+ public Class<? extends Partitioned> getPartitionedType();
+
+ public List<? extends Partitioned> getAllInPartitions(List<String> partitionOrder);
+
+ public List<? extends Partitioned> getAllInPartition(String partitionId);
+
+ public List<? extends Partitioned> getBestInPartitions(List<String> partitionOrder);
+
+ public List<? extends Partitioned> getBestInDefaultPartitions();
+
+ public List<? extends Partitioned> removeWeakPartitionMatches(List<? extends Partitioned> partitioned);
+
+ public List<? extends Partitioned> removeWeakPartitionMatches(List<? extends Partitioned> partitioned, List<String> partitionOrder);
+
+ public DuplicateStrategy getPartitionedDuplicateStrategy();
+
+ public List<String> getDefaultPartitionOrder();
+
+}
\ No newline at end of file
--- /dev/null
+package bug;
+
+import java.util.List;
+
+public aspect PartitionedManagerAspect {
+
+ public Class<? extends Partitioned> PartitionedManager.getPartitionedType(){
+ return (Class<? extends Partitioned>) getManagedType();
+ }
+
+ public List<? extends Partitioned> PartitionedManager.removeWeakPartitionMatches(List<? extends Partitioned> partitioned){
+ return removeWeakPartitionMatches(partitioned, getDefaultPartitionOrder());
+ }
+
+ public List<? extends Partitioned> PartitionedManager.removeWeakPartitionMatches(
+ List<? extends Partitioned> partitioned, List<String> partitionOrder){
+ return new PartitionedPruner().prune(partitioned, partitionOrder);
+ }
+
+ public List<? extends Partitioned> PartitionedManager.getBestInDefaultPartitions(){
+ return getBestInPartitions(getDefaultPartitionOrder());
+ }
+
+ public List<? extends Partitioned> PartitionedManager.getBestInPartitions(List<String> partitionOrder){
+ List<? extends Partitioned> results = getAllInPartitions(partitionOrder);
+ results = removeWeakPartitionMatches(results, partitionOrder);
+ return results;
+ }
+
+ public List<? extends Partitioned> PartitionedManager.getAllInPartition(String partitionId){
+ String queryString = QueryUtils.select(getPartitionedType(), "partitioned") +
+ " WHERE partitioned.partitionId = :partitionId";
+ Query query = createQuery(queryString);
+ query.setParameter("partitionId", partitionId);
+ return query.getResultList();
+ }
+
+ public List<? extends Partitioned> PartitionedManager.getAllInPartitions(List<String> partitionOrder){
+ String queryString = QueryUtils.select(getPartitionedType(), "partitioned") +
+ " WHERE partitioned.partitionId IN (:partitionOrder)";
+ Query query = createQuery(queryString);
+ query.setParameter("partitionORder", partitionOrder);
+ return query.getResultList();
+ }
+
+}
--- /dev/null
+/*
+ * Created on Aug 22, 2008
+ */
+package bug;
+
+public class PartitionedPruner extends NaturallyComparablePruner<Partitioned, String>{
+
+ @Override
+ public String getOrdering(Partitioned object) {
+ return object.getPartitionId();
+ }
+
+}
--- /dev/null
+/*
+ * Created on Sep 18, 2008
+ */
+package bug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class Query {
+
+ public List getResultList(){
+ return new ArrayList<Object>();
+ }
+
+ public Query setParameter(String name, Object value){
+ return this;
+ }
+
+}
--- /dev/null
+/*
+ * Created on Aug 18, 2008
+ */
+package bug;
+
+public class QueryUtils {
+
+ public static String select(Class<?> from, String alias){
+ return select(from, alias, alias);
+ }
+
+ public static String select(Class<?> from, String alias, String target){
+ return "SELECT " + target + " FROM " + from.getName() + " " + alias + " ";
+ }
+
+}
--- /dev/null
+/*
+ * Created on Sep 18, 2008
+ */
+package bug2;
+
+import java.util.List;
+
+import bug.DuplicateStrategy;
+import bug.PartitionedManager;
+
+
+public class FailingManager implements PartitionedManager {
+
+ public Class<Object> getManagedType(){
+ return Object.class;
+ }
+
+ public List<String> getDefaultPartitionOrder() {
+ return null;
+ }
+
+ public DuplicateStrategy getPartitionedDuplicateStrategy() {
+ return null;
+ }
+
+}