< prev index next >

src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitiveProxy.java

Print this page




  64         this.owner = owner;
  65         this.relativeClassName = relativeClassName;
  66     }
  67 
  68     public GraphicsPrimitive makePrimitive(SurfaceType srctype,
  69                                            CompositeType comptype,
  70                                            SurfaceType dsttype) {
  71         // This should never happen.
  72         throw new InternalError("makePrimitive called on a Proxy!");
  73     }
  74 
  75     //
  76     // Come up with the real instance.  Called from
  77     // GraphicsPrimitiveMgr.locate()
  78     //
  79     GraphicsPrimitive instantiate() {
  80         String name = getPackageName(owner.getName()) + "."
  81                         + relativeClassName;
  82         try {
  83             Class<?> clazz = Class.forName(name);
  84             GraphicsPrimitive p = (GraphicsPrimitive) clazz.newInstance();

  85             if (!satisfiesSameAs(p)) {
  86                 throw new RuntimeException("Primitive " + p
  87                                            + " incompatible with proxy for "
  88                                            + name);
  89             }
  90             return p;
  91         } catch (ClassNotFoundException ex) {
  92             throw new RuntimeException(ex.toString());
  93         } catch (InstantiationException ex) {
  94             throw new RuntimeException(ex.toString());
  95         } catch (IllegalAccessException ex) {
  96             throw new RuntimeException(ex.toString());
  97         }
  98         // A RuntimeException should never happen in a deployed JDK, because
  99         // the regression test GraphicsPrimitiveProxyTest will catch any
 100         // of these errors.
 101     }
 102 
 103     private static String getPackageName(String className) {
 104         int lastDotIdx = className.lastIndexOf('.');
 105         if (lastDotIdx < 0) {
 106             return className;
 107         }
 108         return className.substring(0, lastDotIdx);
 109     }
 110 
 111     public GraphicsPrimitive traceWrap() {
 112         return instantiate().traceWrap();
 113     }
 114 }


  64         this.owner = owner;
  65         this.relativeClassName = relativeClassName;
  66     }
  67 
  68     public GraphicsPrimitive makePrimitive(SurfaceType srctype,
  69                                            CompositeType comptype,
  70                                            SurfaceType dsttype) {
  71         // This should never happen.
  72         throw new InternalError("makePrimitive called on a Proxy!");
  73     }
  74 
  75     //
  76     // Come up with the real instance.  Called from
  77     // GraphicsPrimitiveMgr.locate()
  78     //
  79     GraphicsPrimitive instantiate() {
  80         String name = getPackageName(owner.getName()) + "."
  81                         + relativeClassName;
  82         try {
  83             Class<?> clazz = Class.forName(name);
  84             GraphicsPrimitive p =
  85                 (GraphicsPrimitive) clazz.getDeclaredConstructor().newInstance();
  86             if (!satisfiesSameAs(p)) {
  87                 throw new RuntimeException("Primitive " + p
  88                                            + " incompatible with proxy for "
  89                                            + name);
  90             }
  91             return p;
  92         } catch (ReflectiveOperationException ex) {




  93             throw new RuntimeException(ex.toString());
  94         }
  95         // A RuntimeException should never happen in a deployed JDK, because
  96         // the regression test GraphicsPrimitiveProxyTest will catch any
  97         // of these errors.
  98     }
  99 
 100     private static String getPackageName(String className) {
 101         int lastDotIdx = className.lastIndexOf('.');
 102         if (lastDotIdx < 0) {
 103             return className;
 104         }
 105         return className.substring(0, lastDotIdx);
 106     }
 107 
 108     public GraphicsPrimitive traceWrap() {
 109         return instantiate().traceWrap();
 110     }
 111 }
< prev index next >