wei ma

Ranch Hand
+ Follow
since Jul 18, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by wei ma

Thank you very much. I did some googling about SecurityManager and found this http://www.onjava.com/pub/a/onjava/2007/01/03/discovering-java-security-requirements.html.
So, security manager can be configured. Can I use something like setProperty() in code to do this configuration at runtime?
15 years ago

Punit Singh wrote:Wei, nice example, but reflection is very powerful tool, it can make many things possible in Java, it can make String objects mutable from immutable.


So better leave Reflection API untouched, otherwise it will break all the oops concepts.

I got this code from here:
http://radio.javaranch.com/corey/2004/08/02/1091465913000.html




OMG I must be living in a java Matrix before. Now it's time to take a pill for the truth. Thanks for waking me up, Punit. I started another topic regarding to this. Would you follow me there? https://coderanch.com/t/426829/Java-General-intermediate/Mutable-String#1893738
This all started with SCJP discussion. https://coderanch.com/t/426765/Programmer-Certification-SCJP/Argumentdefined-anonymous-class-call
But it came to a point that it's no longer relevant to SCJP, so I will continue here.
Punit showed a way of making Strings mutable. And after a little hacking, I make an example of possible way of cracking people's data. Look at the following code:


If I put this kind code as a plugin for some existing application. Would I be able to produce bugs that are almost impossible to detect? I am sure there must be some way to prevent this from happening. Can some security gurus tell me how?
15 years ago

Henry Wong wrote:Do you mean, given this....



How do you call the sizzle() method, of the anonymous inner class that subclasses the popcorn class?

The answer is... You can't. The sizzle method is not defined by any of its super classes or interfaces (which are still in scope).

Henry




I have posted before but my post seems get lost, so I will post again.
K&B says you cannot do it. So, for the sake of SCJP, I will pretend we can't do it. However, as a curious Java junkie, I believe that K&B is hiding something from us. So I did some research and this is what I found:


It's not a good example of "best practice of OO programming", but it made the point: It is possible to call method declared inside an anonymous class.
I believe this is deeper than what SCJP requires. But yes, I agree with you. The underline implementation of ArrayList is array, so inserting element would be a pain when the original array is full and you have to expand the size. However, retrieving element from array is fast, all you need to do is
while in linkedList your have to do:



Banu Chowdary wrote:What does it mean???

When using HashSet or LinkedHashSet, the objects you add to them
must override hashCode(). If they don’t override hashCode(), the default Object.
hashCode() method will allow multiple objects that you might consider "meaningfully
equal" to be added to your "no duplicates allowed" set. (K&S)



Well, a set is only supposed to contain UNIQUE elements. So, the problem comes to what is the definition of unique. For many of us (and probably the get() methods implementations of the List interface), as long as equals(Object o) method returns true, we will consider two objects to be the same. But for HashSet and LinkedHashSet, two conditions has to be met: 1) equals method returns true, and 2) the return value of hashCode for two objects has to be the same value. Therefore, if one wants to use HashSet and LinkedHashSet in a "meaningful" way, one has to override both equals and hashCode methods.

alex sandoval wrote:Hi everyone! I will be taking SCJP tomorrow in the morning (GMT+8). I am doing the final exam of ExamLab by Devaka Cooray (Thanks Devaka great simulator!).

I just want to make sure if question 19 of Final exam from ExamLab is correct. It says that LinkedHashSet is faster than HashSet because it is doubly-linked. Is it true? Because I researched the API didn't find any statement that it is faster than HashSet or any other Set implementations because of its doubly-linked elements. Hope you may help me clear my thoughts before taking the exam tomorrow.

By the way, wish me luck guys! Thanks



K&B page 564.

Because LinkedHashSet maitains a doubly linkedlist, it will be slower for insertion and removing, but will be slightly faster in iteration.

Not exactly same word, what that basically what it means. Good luck for your exam!
This make me think about the law systems in different countries. In North America, one is "Innocent until proven guilty". In some other systems, one is "Guilty until proven innocent". I guess Sun's did not make SCJP to reflect the law system of the states.
I took the master exam yesterday and got 68%. Then I thought I would practice on the quiz,and each time I got around 60%. Suddenly, I felt sick about the long questions and start a new strategy and all of the sudden I was getting 87%!!!
Here is what I did:
1. If a long question appear, go directly to the answers without even look at the question.
2. Hope fully I will find a candidate answer as "Compilation error".
3. Start looking madly for possible places that might cause compilation errors.
4. Find a problem is the question code, and choose the "Compilation error" choice as your answer.

I guess our problem is that when take the exam, we unconsciously assumes the questions contain no syntax error, and dive directly into the logic. And the logic is usually twisted in a way to confuse us as much as possible, and eventually, we loose our patients and just randomly pick an answer and pray.

I personally disagree with this way of making test. But I guess this is Sun's intention to make sure programmers can at least write code to pass compiler's check before they can write anything meaningful.

I have been trying to download Devaka's simulator for the past a few days and always get the same "link not found" error. I don't know if it's because the "great firewall of china" because the site is down. I have heard good things about this simulator and am very interested in trying it. Is it any other way to obtain the software other than downloading from Devaka's site?

Hi ranchers,
After many years of "wanting to take scjp", I finally bought the voucher this afternoon. Then I took the John Meyer's exam and got 67%. How much more do you think I should study?
Could it be the white spaces got truncted ? Maybe you should print out the retuning document to see the difference.
20 years ago
I have installed the WASP UDDI server. When run the serverstart.bat file from command line
I got some messages telling me everything works fine:
===========================================
INFO: com.idoox.wasp.WaspImpl - Starting Systinet WASP Server for Java/4.0SP2 (J
ava/1.4.1_01; Windows NT/4.0)
INFO: com.idoox.config.xml.ConfigStore - Starting configStore with savingPeriod
2000
INFO: com.systinet.wasp.admin.PackageRepositoryImpl - Registering package [][htt
p://systinet.com/wasp/app/uddi/4.5][uddi][1.0]
INFO: com.systinet.wasp.admin.PackageRepositoryImpl - Registering package [][htt
p://systinet.com/wasp/app/uddiclient/4.5][uddiclient][1.0]
INFO: com.systinet.wasp.admin.PackageRepositoryImpl - Loading package [][http://
systinet.com/wasp/app/uddiclient/4.5][uddiclient][1.0]
INFO: com.systinet.wasp.admin.PackageRepositoryImpl - Loading package [][http://
systinet.com/wasp/app/uddi/4.5][uddi][1.0]
INFO: com.idoox.wasp.server.Connector - Starting connector server on port 8081
INFO: com.idoox.wasp.security.client.CurrentImpl - No default security provider
configured
INFO: com.idoox.transport.http.server - Starting 'https' server on port 8443
INFO: com.idoox.transport.http.server - Starting 'http' server on port 8080
INFO: com.idoox.wasp.server.ServiceManager - Binding Service Manager to Transpor
t protocols
INFO: com.idoox.wasp.server.ServiceManager - Loading services marked to be loade
d on startup
INFO: com.systinet.uddi.web.UDDIRawService - Starting Systinet WASP UDDI, 4.5
*****************************************
* This product includes Hypersonic SQL. *
*****************************************
INFO: com.idoox.wasp.WaspImpl - WASP is started
================================================
but when I try to point my web browser to
http://localhost:8080
I got the famouse 404 error message.
I have tried on both Windows NT and XP, got the same results. Is there anything that I have missed? Does anyone had similar exprience?
Thanks!
21 years ago
I am working on implementing Web Services with Axis as well. I have been using the WSDL viewer plug-in from improve technologies since last year. Everything works fine so far, and I am looking into using the Axis plug-in soon.