Kartik Patel

Ranch Hand
+ Follow
since Sep 12, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kartik Patel

I am rewriting one of the existing structures in this new structure of hashmaps. So, want to compare the memory both the implementations occupy.
16 years ago
Hi,
I am writing one structure having maps of maps and at end of it , I want to know the memory size of that structure.

Is there any way, I can achieve that? What about writing into a bytestream and checking number of bytes, will this give me correct result?
16 years ago
Hi,
I have classes,
class Foo{
public void A(int c,int d) throws Exception
{
}
}

class Bar extends Foo{
public static void main(String args[])
{
Bar b=new Bar();
b.A(10,10);
}
}

I want to put before pointcut on method A. I am using loadtime weaving so binding to perticular class happens from aop.xml

my pointcut is defined something like this
public abstract aspect point();
before(Bar bar,int i1,int i2):execution(public void A(int c,int d) throws Exception) && this(bar) {
//Do something
}

aop.xml looks like
<pointcut name="point"
expression="within(Bar)"/>
</concrete-aspect>

Somehow its not working.. Can anyone please help ? Its real urgent.
Hi,
I am new to XML world. I am trying to validate one xml using xsd. xml and xsd both are in seperate jars but in classpath

Here is the snippet of the xsd,xml and code

XSD
<?xml version="1.0" encoding="UTF-8" ?>
- <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.metrics.org/MetricsConfiguration" targetNamespace="http://www.metrics.org/MetricsConfiguration" elementFormDefault="qualified">
......

XML
<?xml version="1.0" encoding="UTF-8"?>
<tns:MetricConfiguration xmlns:tns="http://www.metrics.org/MetricsConfiguration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.metrics.org/MetricsConfiguration config/schema/MetricsConfiguration.xsd">
<tns:Metrics>......


[ December 11, 2008: Message edited by: Martijn Verburg ]
So does that mean "Injecting dependency" = "Client not asking for any object (the way it is asking in service locator), but some background process generates the Object / dependency for me and add it to client code without knowing client."

Will my bytecode change? How can I ensure that NullPointerException won't get generated at the time using that object as I am not aware when the object instantiation is taking place in case of DI. Its some callback method or may be framework's thread is responsible for generating the object.
16 years ago
Can I say, Service locator is one of the way to implement DI? DI is just a cleaner approach of getting desired object. Where as SL is more simpler when it comes to debugging the code?

Does this sound good?
16 years ago
Thanks Rob. The explanation was quite informative.
16 years ago
I am talking about this. See following tree
Vehicle
Honda Tata
City Civic Indigo Indica

Check this:

class Vehicle {}
class Honda extends Vehicle {}
class Tata extends Vehicle {}
class City extends Honda {}
class Civic extends Honda {}
class Indica extends Tata {}
class Indigo extends Tata {}

List<? super Honda> ls=null;

Honda honda=new Honda();
Civic civic=new Civic();
Vehicle vehicle=new Vehicle();


ls.add(honda); // Fine Honda super Honda
ls.add(civic); // ITS WORKING WHY??? civic is not super of Honda
ls.add(vehicle); // Its not WORKING WHY??? Vehicle super Honda right?


Please suggest..
16 years ago

Originally posted by Rob Prime:


With List<? super Double>, you know that the generic type is a Double or any of its super classes - Number or Object. So let's consider the options:
List<Double> - no problem in adding a Double here
List<Number> - a Double is a Number, so no problem here either
List<Object> - anything is an object, so no problem here either



I think adding List<Number> and List<Object> won't compile in case of List<? super Double>. Only List<Double> will compile. Please try.
16 years ago
Why upper bound wildcard generics make the collection readonly but same not apply for lower bound wildcard collection?

List<? extends Number> l= new ArrayList<Integer>();
Number n1= new Double(1.0);
l.add(n1) // won't compile

List<? super Double> l= new ArrayList<Number>();
Number n1= new Double(1.0);
Double n2= new Double(1.0);
l.add(n1) // won't compile
l.add(n2) // will compile
16 years ago
Can anyone please let me know why Type variables are not bound?

Can't I write List<Number extends Comparable>?

How can I make sure that only List of Numbers which extends comparable should be residing in particular list?
16 years ago
Peter,
Thanks for reply.
Here is what I understood from the solutions given by you:
1.
Object o=new Object();
synchronized(o)
{

}

Does it make sense? I am creating an object and covering it with Sync block. Its as good as not having sync block because I am taking a lock on the different object and may be in sync block, I am changing value for some other object.

2. If I store o (created in first Example) as key to Map and say, I have stored some value against that key. While getting value I need to pass very same object as Hashcode method of Object class will create new hashcode for each new object. I won't be able to get my value from Map until and unless I pass exactly same key(in this case o)

So this won't work:
Map m=new HashMap();
m.put(o,"ONE");
Object o1=new Object();
m.get(o1);

Than what is the use of having Object o as key, If I can not get value out of map
16 years ago
Why Object class is not abstract? There are no private methods which will be required?
In other words, in which cases I would do following:
Object o=new Object();

Why would I instantiate Object class?
16 years ago